i am trying to disable dark mode in my app and its working on android 10 or higher but its not working on android 9. Can anyone please help me out here. Thanks in advance.
In on create method i have done below,
in theme or theme(night), in both files i placed
<style name="Theme.VideoTradieProvider" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- <style name="Theme.VideoTradieProvider" parent="Theme.MaterialComponents.Light.NoActionBar">-->
<!-- Primary brand color. -->
<item name="android:windowActivityTransitions">true</item>
<!-- <item name="android:windowEnterTransition">#transition/explode_old</item>-->
<!-- <item name="android:windowExitTransition">#transition/explode_old</item>-->
<item name="colorPrimary">#color/purple_500</item>
<item name="colorPrimaryVariant">#color/purple_700</item>
<item name="colorOnPrimary">#color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#color/teal_200</item>
<item name="colorSecondaryVariant">#color/teal_700</item>
<item name="colorOnSecondary">#color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">#color/white</item>
<item name="android:windowLightStatusBar">true</item>
<!-- Customize your theme here. -->
</style>
also write below line but not working with anroid 9
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
Change the parent attribute of your app style in themes.xml from
<style name="Theme.AppName" parent="Theme.MaterialComponents.DayNight.NoActionBar">
to
<style name="Theme.AppName" parent="Theme.MaterialComponents.Light.NoActionBar">
Is it Right As Josh and another way to see if You have the theme(night) then delete it
Related
I am making a notes app.In that app i want an actionmode to trigger when long pressed on any item.It works but i cant change any style attributes of the actionmode.I have included my custom style in the styles.xml of my app, still doesn't work
styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="Theme.MyApplication" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#color/white</item>
<item name="android:textColor">#color/black</item>
<item name="colorPrimaryVariant">#color/blue_main</item>
<item name="colorOnPrimary">#color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#color/white</item>
<item name="colorSecondaryVariant">#color/white</item>
<item name="colorOnSecondary">#778899</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="m">#D3D3D3</item>
<item name="android:actionBarStyle" >#style/Theme.AppCompat.Light</item>
<item name="actionModeStyle">#style/Widget.ActionMode</item>
<item name="actionBarTheme">#style/Theme.AppCompat.Light</item>
</style>
<style name="Widget.ActionMode" parent="#style/Widget.AppCompat.Light.ActionMode.Inverse">
<item name="background">?attr/actionModeBackground</item>
<item name="android:actionBarDivider">#null</item>
<item name="actionModeCloseDrawable">#drawable/cancel</item>
<item name="android:actionModeBackground">#android:color/white</item>
</style>
<style name="CustomMaterialDialog" parent="#style/ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<!-- Background Color-->
<item name="android:background">#FFFFFF</item>
<!-- Text Color for title and message -->
<item name="colorOnSurface">#BF40BF</item>
<!-- Text Color for buttons -->
<item name="colorPrimary">#BF40BF</item>
<item name="shapeAppearanceOverlay">#style/ShapeAppearance.MaterialComponents.LargeComponent
</item>
</style>
</resources>
I specifically want to remove a green divider line that shows up at the bottom of the contextual menu i have attached the picture please see green divider line below the action mode menu
solved it. The problem was with the theme applied to the custom toolbar that i implemented. applied the lighttheme and everything works fine
Whenever i try to change my apps theme, it changes in the preview ,but always stays the same in the emulator. Why is this?
Here is my style.xml:
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/colorPrimary</item>
<item name="android:statusBarColor">#color/colorPrimaryDark</item>
</style>
</resources>
I would like to change the color of my settings Tab located on the ActionBar, I have done very extensive research here and in other sources.
My Android version is 4.4.2.
My manifest is declared this way:
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="19" />
Basically I am doing what other sources showed me to:
<style name="AppBaseTheme" parent="android:style/Theme.Holo.Light">
</style>
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:panelFullBackground">#drawable/menu_background</item>
</style>
I also have replaced the android:panelFullBackground property for android:panelBackground, android:panelColorBackground and android:panelColorForeground switching from drawable resources to color values for each without results.
Finally I have also tried using ListPopupWindow parent variant:
<style name="AppBaseTheme" parent="android:style/Theme.Holo.Light">
</style>
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:popupMenuStyle">#style/PopupMenu</item>
</style>
<style name="PopupMenu" parent="#android:style/Widget.Holo.ListPopupWindow">
<item name="android:panelFullBackground">#drawable/menu_background</item>
</style>
Here I have also switched the android:panelFullBackground property for android:panelColorBackground and android:popupBackground properties mixing them up with #android:color and #drawable resources too but is not working either.
Can you please tell me an effective way to configure this through the styles.xml file?
Thank you very much
Maybe you need to use Android Asset studio's ActionBarStyleGenerator to easily handle colors and not going through all the stuff. If you need more customizing on each Tab then you need to get a reference to actionbar using getActionBar()(or getSupportActionBar() in case of support actionbar) and create custom views Programmatically and add them to your actionbar using addTab(...)
I managed to find the right setting for my styles to accomplish the action bar settings custom color. This post helped as well: How to change the background color of Action Bar's Option Menu in Android 4.2?
The styles go this way:
File styles.xml:
<resources>
<style name="AppBaseTheme" parent="android:style/Theme.Holo.Light">
</style>
<style name="AppTheme" parent="android:Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBarTheme</item>
<item name="android:popupMenuStyle">#style/PopupMenu</item>
<item name="android:itemTextAppearance">#style/TextAppearance</item>
</style>
<style name="MyActionBarTheme" parent="#android:Widget.Holo.Light.ActionBar">
<item name="android:background">#3892D3</item>
<item name="android:titleTextStyle">#style/MyActionBarTheme.Text</item>
</style>
<!--
This style reference did it, you can put a drawable resource or color resource reference there as well. For example: #drawable/menu_dropdown_image or #android:color/white
-->
<style name="PopupMenu" parent="#android:Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">#3892D3</item>
</style>
<!---->
<style name="MyActionBarTheme.Text" parent="#android:TextAppearance">
<item name="android:textColor">#android:color/white</item>
<item name="android:textSize">20sp</item>
</style>
<style name="TextAppearance">
<item name="android:textColor">#android:color/white</item>
</style>
</resources>
Thank you!
Here's my styles.xml file:
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="MyCustomTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBarTheme</item>
<item name="android:actionMenuTextColor">#style/TitleBarTextColor</item>
</style>
<style name="MyActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#060EBB</item>
</style>
<style name="MyActionBarTitleText"
parent="#style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#00B300</item>
</style>
<style name="TitleBarTextColor" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#00B300</item>
</style>
</resources>
Here's my manifest file:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/MyCustomTheme" >
The background of the ActionBar is changing color the way I want it to, but the text itself isn't. What am I doing wrong? Oh, and some explanation of the way styles.xml works within Android would be nice too. It seems to be very confusing.
change your
code from
<style name="MyActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#060EBB</item>
</style>
to
<style name="MyActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#060EBB</item>
<item name="android:titleTextStyle">#style/TitleColor</item>
</style>
<style name="TitleColor" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#00B300</item>
</style>
Style.xml
style.xml file states what are the styles you want to use in your app, basically it inherits android default style
as you can see in every style tag which ever property you want to set you give it a name
<style name="TitleColor" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
and say what property of parent style you want to override, Parent style is the theme which you selected as default theme when you created app.
I'm using in my style.xml as main app theme
<style name="AppTheme" parent="Theme.AppCompat.Light">
And all AlertDialogs using same white/blue colors. But i have Activities which working as Dialog parent="android:Theme.Dialog" and this box use dark theme. How could I change it to AppCompat.Light theme?
I tryed Theme.AppCompat.Light.Dialog but as you know it doesn't working well.
Thanks.
You can use this theme:
<style name="AppTheme" parent="android:Theme.DeviceDefault.Light.Dialog">
Or this:
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light">
<!-- API 14 theme customizations can go here. -->
</style>
<style name="MyAppCompatDialogTheme" parent="AppBaseTheme">
<item name="android:windowIsFloating">false</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowSoftInputMode">stateAlwaysHidden</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="android:windowIsTranslucent">true</item>
</style>
source last code