Change android:Theme.Dialog to Light AppCompat Dialog - java

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

Related

I want to change title bar text color in material Components theme. Any help will be greatly appreciated

I tried set title color but it is deprecated. I tried to change color by using
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyTheme.ActionBarStyle</item>
</style>
<style name="MyTheme.ActionBarStyle" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/red</item>
</style>
as mentioned here: ActionBar text color but the whole Titlebar color changes to white while doing it.
All I want to do is set my Black Title bar text color to white.
I also tried this solution here: Change color title bar but I am using the MaterialComponents theme and using AppCompactThemes makes my app crash.
Assuming that you are not using a Toolbar the textcolor used in the ActionBar is based on the attribute android:textColorPrimary.
You can override it adding in your app theme the actionBarTheme attribute:
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
<item name="actionBarTheme">#style/ThemeOverlay.Actionbar</item>
</style>
with:
<style name="ThemeOverlay.Actionbar" parent="ThemeOverlay.MaterialComponents.ActionBar.Surface" >
<item name="android:textColorPrimary">#color/....</item>
</style>
As alternative you can
just add this to you base theme
<item name="titleTextColor">#android:color/holo_red_dark</item> //whatever color
Eg:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="titleTextColor">#android:color/holo_green_dark</item>
</style>

Change action bar Title font & color

I wanna change my action bar title font & color. so now im doing like this code. also i'm using typekit library too. i dont know why not change now
plz have some advice for me
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorCyanAzure</item>
<item name="colorPrimaryDark">#color/colorWhite</item>
<item name="colorAccent">#color/colorMelon</item>
<item name="android:actionBarStyle">#style/AppTheme.MyActionBar</item>
</style>
<style name="AppTheme.MyActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">#style/MyTheme.MyActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.MyActionBar.TitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/colorWhite</item>
<item name="android:textStyle">normal</item>
</style>
Change you Theme.AppCompat.Light to Theme.AppCompat.Light.DarkActionBar and tried code as below
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="AppTheme.MyActionBar"parent="#style/Widget.AppCompat.ActionBar.Solid">
<item name="titleTextStyle">#style/MyTitleTextStyle</item>
</style>
<style name="MyTheme.MyActionBar.TitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/colorWhite</item>
<item name="android:textStyle">normal</item>
</style>
You could use a toolbar. When you have a reference to the toolbar and you want to style the title, you could do something like this
TextView textView = (TextView)toolbar.getChildAt(0);
//set the font and font color.
If you have more children in the toolbar, you may want to loop through and find the child you want to style

Custom Background Color for ActionBar settings area

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!

How to change the title text color and the color of the background on the ActionBar?

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.

Why can't I change my actionbar text color?

I used this generator to create a custom theme for my app:
http://jgilfelt.github.io/android-actionbarstylegenerator/
But there is one thing that i want to change, that this generator does not support:
The textcolor of the actionbar.
I tried doing this manually with this code:
<resources>
<style name="Theme.Bessel" parent="#android:style/Theme.Holo.Light">
<item name="android:titleTextStyle">#style/MyTextAppearance</item>
</style>
<style name="MyTextAppearance" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#F8F8FF</item>
</style>
</resources>
But the textcolor of my actionbar remains unchanged. Any tips?
Update:
<resources>
<style name="Theme.Bessel" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/Your.ActionBar</item>
</style>
<style name="Your.ActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">#drawable/ab_background_textured_bessel</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_bessel</item>
<item name="android:backgroundSplit">#drawable/ab_background_textured_bessel</item>
<item name="android:progressBarStyle">#style/ProgressBar.Bessel</item>
<item name="android:titleTextStyle">#style/MyTextAppearance</item>
</style>
<style name="MyTextAppearance" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#F8F8FF</item>
</style>
</resources>
You need to be applying android:titleTextStyle to a style that is inherent of Widget.ActionBar. So, it looks like in your case that would be Widget.Holo.Light.ActionBar.
<style name="Your.ActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">#style/MyTextAppearance</item>
</style>
Then apply your ActionBar style in your root theme using android:actionBarStyle.
<style name="Theme.Bessel" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/Your.ActionBar</item>
</style>
To change the tab text color, you need a theme that inherits Widget.ActionBar.TabText, in your case that looks like it'll be Widget.Holo.Light.ActionBar.TabText. Then to apply the style use android:actionBarTabTextStyle in your root theme.
<style name="Theme.Bessel" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarTabTextStyle">#style/Your.Widget.ActionBar.TabText</item>
</style>
<style name="Your.Widget.ActionBar.TabText" parent="#android:style/Widget.Holo.Light.ActionBar.TabText">
<item name="android:textColor">#F8F8FF</item>
</style>

Categories

Resources