Lollipop Theme issue

2019-07-04 21:52发布

问题:

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 .

回答1:

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>


回答2:

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.



回答3:

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.