Lollipop Theme issue - android

I am using sherlock action bar in my project, I have used Theme.Sherlock.Light.DarkActionBar
<style name="AppTheme" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="android:homeAsUpIndicator">#drawable/transparent</item>
<item name="homeAsUpIndicator">#drawable/transparent</item>
<item name="actionBarStyle">#style/Widget.MyTheme.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.MyTheme.ActionBar</item>
<item name="android:titleTextStyle">#style/Widget.MyTheme.TitleTextStyle</item>
<item name="android:textAllCaps">false</item>
</style>
Problem :
I am getting light color menu with lollipop:
pre lollipop image :
Lollipop image :
can some one guide me, how can I get slimier menu color on both .

You can create a style which extends from actionbar sherlock to change color of you actionbar with other properties.
<style name="Theme.MyTheme" parent="Theme.Sherlock.ForceOverflow">
<item name="actionBarStyle">#style/Widget.MyTheme.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.MyTheme.ActionBar</item>
</style>
<style name="Widget.MyTheme.ActionBar" parent="Widget.Sherlock.ActionBar">
<item name="android:background">#ff000000</item>
<item name="background">#ff000000</item>
<item name="android:textColor">#CC3232</item>
</style>
For TextColor only
<style name="YOURTHEME.ActionBar.TitleTextStyle" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#color/yourColor</item>
<item name="textColor">#color/yourColor</item>
</style>
Last resort Solution
<item name="android:textColorPrimary">#color/yourColor</item>

You should create a new styles.xml in a separate values-21 folder. There, you can define a specific theme/style that suits your needs for Lollipop devices only.

You should be using the ActionBar or ToolBar provided by app-compat library, instead of ActionBarSherlock.
ABS uses replacement Holo themes for older versions, which I guess hasn't been updated in a while.

Related

Light theme action bar have weird artefact since AppCompat v21

Since I upgraded appcompat to v21 (now on v22.2.1), when using light theme, the action bar have a very odd artefact as seen on the screenshot below. When using dark theme, no problems whatsoever!
I tried to change the style of the action bar using this and it works, however there's no more title! All other ActionBar styles are showing the artefact.
<item name="actionBarStyle">#style/Widget.AppCompat.Light.ActionBar.TabBar</item>
Here are my dark/light themes definitions:
<style name="AT_Theme" parent="#style/Theme.AppCompat">
<item name="android:windowBackground">#android:color/black</item>
<item name="android:colorBackground">#android:color/black</item>
<item name="android:textColorPrimary">#ffffffff</item>
<item name="switchStyle">#style/switch_dark</item>
<item name="android:textAppearanceButton">#style/CustomTheme.ButtonTextAppearance</item>
<item name="android:listChoiceIndicatorSingle">#drawable/abc_btn_radio_material_light</item>
<item name="android:listChoiceIndicatorMultiple">#drawable/abc_btn_check_material_light</item>
</style>
<style name="AT_Theme_Light" parent="#style/Theme.AppCompat.Light">
<item name="android:windowBackground">#android:color/white</item>
<item name="android:colorBackground">#android:color/white</item>
<item name="android:textColorPrimary">#ff000000</item>
<item name="switchStyle">#style/switch_light</item>
<item name="android:textAppearanceButton">#style/CustomTheme.ButtonTextAppearance</item>
<item name="android:listChoiceIndicatorSingle">#drawable/abc_btn_radio_material</item>
<item name="android:listChoiceIndicatorMultiple">#drawable/abc_btn_check_material</item>
</style>
I tried tweaking/overriding a lot of things to no avail. Also search for a color definition or drawable that would do that, no result there either.
Please help me get rid of that artefact:
Turns out the solution was so simple:
1) Change actionBarStyle in app's custom theme, both light/dark works with this:
<item name="actionBarStyle">#style/Widget.AppCompat.Light.ActionBar.Toolbar</item>
2) Enable title in code:
ActionBar ab = aba.getSupportActionBar();
if (ab != null)
ab.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE,ActionBar.DISPLAY_SHOW_TITLE);

Why isn't the action bar text color changing?

I am on android lollipop and using the following style as my theme MyNavigationDrawerTheme
in styles v14
<style name="MyNavigationDrawerTheme" parent="MaterialNavigationDrawerTheme.Light">
<item name="actionMenuTextColor">#color/white</item>
</style>
in material drawer theme.xml (mostly irrelevant to this issue)
<style name="MaterialNavigationDrawerTheme.Light" parent="Theme.AppCompat.Light.NoActionBar" >
<item name="drawerType">#integer/DRAWERTYPE_ACCOUNTS</item>
<item name="drawerColor">#fafafa</item>
</style>
I understand that the theme Theme.AppCompat.Light.NoActionBar has black text for the action bar but why isn't it changing when I include the line
<item name="actionMenuTextColor">#color/white</item>
I have been trying to fix this for almost two days now tried so many things (eg here) but nothing works
Any idea
you could try this in styles.xml:
<style name="MyNavigationDrawerTheme" parent="MaterialNavigationDrawerTheme.Light">
<item name="android:actionMenuTextColor">#color/white</item>
<item name="android:actionMenuTextAppearance">#style/TextAppearance.ActionMenu
</item>
</style>
<style name="TextAppearance.ActionMenu">
<item name="android:textColor">#color/white</item>
</style>
ps:
yeah ,sometimes it won't works only by android:actionMenuTextColor ,such as Galaxy S4
just add attr android:actionMenuTextAppearance
In case you are using Toolbar, this is how you do it -
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:textColorPrimary">#android:color/holo_red_dark</item>
<item name="textColorPrimary">#android:color/holo_red_dark</item>
<!-- Customize your theme here. -->
</style>
Should work like a charm :)

Change Android 5.0 Actionbar color

I'm working with the new Lollipop Material Design guidelines and would like to incorporate that nifty navigation drawer animation in my app. I've gotten that far, by using the android.support.v7.app.ActionBarDrawerToggle, but now I'm having difficulty changing the color of said action bar. It stays bright gray no matter what I set the theme to. How would one go about changing the color of the actionbar? This is what my app theme looks like:
//res/values/styles.xml
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/ActionBar</item>
<item name="android:colorPrimary">#color/primaryDef</item>
<item name="android:colorPrimaryDark">#color/primaryDarkDef</item>
<item name="android:activatedBackgroundIndicator">#drawable/defbg</item>
<item name="android:colorAccent">#color/primaryDef</item>
<item name="android:navigationBarColor">#color/primaryDarkDef</item>
</style>
<style name="ActionBar" parent="android:Widget.ActionBar">
<item name="android:background">#color/primaryDef</item>
</style>
AppCompat does not use the android: prefixed attributes for the Material Theme color palette items per the migration guide to v21 by the author of AppCompat. Instead, just use the names themselves:
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/primaryDef</item>
<item name="colorPrimaryDark">#color/primaryDarkDef</item>
<item name="colorAccent">#color/primaryDef</item>
<item name="android:navigationBarColor">#color/primaryDarkDef</item>
<item name="android:activatedBackgroundIndicator">#drawable/defbg</item>
</style>
The Action Bar will be colored by colorPrimary.

Android: Can't style ActionBar menu text

I'm trying to create a custom styling for the ActionBar. Specifically i'm trying to change the menu item color.
I applied these stylings:
<style name="MyActionBar" parent="#style/Widget.Sherlock.Light.ActionBar">
<item name="android:actionMenuTextAppearance" tools:ignore="NewApi">#style/MyActionBarMenuText</item>
<item name="android:background">#drawable/actionbar_bg</item>
<!-- Support library compatibility -->
<item name="actionMenuTextAppearance">#style/MyActionBarMenuText</item>
<item name="background">#drawable/actionbar_bg</item>
</style>
<style name="MyActionBarMenuText" parent="#style/TextAppearance.Sherlock.Widget.ActionBar.Menu">
<item name="android:actionMenuTextColor" tools:ignore="NewApi">#color/actionbar_text</item>
<item name="actionMenuTextColor">#color/actionbar_text</item>
<!-- The textColor property is backward compatible with the Support Library -->
</style>
The background is applying but the menu text colour is not. What am i missing?
I know this was asked many times, but none of the solutions helped me.
Finally got it, Since android:actionMenuTextColor is defined in Theme.Sherlock.Light I needed to add it to my main custom theme which inherits from it and not to the style that inherits from Widget.Sherlock.Light.ActionBar:
<style name="MyTheme" parent="#style/Theme.Sherlock.Light">
<item name="android:actionBarStyle" tools:ignore="NewApi">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="android:actionMenuTextColor" tools:ignore="NewApi">#color/actionbar_text</item>
<item name="actionMenuTextColor">#color/actionbar_text</item>
</style>

can't change color of actionBar divider

I tried change color of my actionBar divider , but nothing work. I' using android support library v7 for support old devices and custom style, and i also change all action bar drawable, but nothing happend!
<resources>
<style name="MyTheme" parent="Theme.AppCompat">
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent = "Widget.AppCompat.ActionBar">
<item name="background">#drawable/my_action_bar</item>
</style>
</resources>
And my ide show me strange error in layout , why did i get this error? it's not color value
java.lang.NumberFormatException: Color value '#drawable/abs__ab_transparent_dark_holo' must start with #
Solution: Need to add android namespace if use for api level >= 14 .May be it will be helpful to someone.
It is because the "divider" is an image. It's hardcoded in the Holo theme assets.
Look at platforms/android-19/data/res/drawable-xxhdpi/ab_transparent_dark_holo.9.png
The style is declared here for holo dark.
<style name="Widget.Holo.ActionBar" parent="Widget.ActionBar">
...
<item name="android:background">#android:drawable/ab_transparent_dark_holo</item>
...
</style>
It's a background. You will need to change the color in the image and replace the background of your bar.
It also needs different sizes for different resolutions.
Maybe you should set color directly, change your theme as
<item name="android:divider">#color/dividercolor</item>
Then you should add color dividercolor in you /value/color file,like
<item name="dividercolor"> #0099CC </item>
I hope this will be helpful to you
<style name="CustomTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyTheme.ActionBarStyle</item>
<item name="android:actionBarDivider">#drawable/action_vertical_doted</item>
<item name="android:actionButtonStyle">#style/MyTheme.ActionBar.ActionButton</item>
<item name="android:actionMenuTextColor">#ffffff</item>
<!-- <item name="android:actionMenuTextAppearance">#style/MyTheme.Menu.FontStyle</item> -->
<!-- <item name="android:actionBarSize">50dp</item> -->
</style>
<style name="MyTheme.ActionBarStyle" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="android:background">#drawable/actionbar_bg_shap</item>
<item name="android:displayOptions">none</item>
<item name="android:backgroundSplit">#drawable/actionbar_bg_shap</item>
</style>
<style name="MyTheme.ActionBar.ActionButton" parent="#android:style/Widget.Holo.Light.ActionButton">
<item name="android:background">#drawable/main_button_inactive_tr</item>
</style>

Categories

Resources