Search code examples
androidandroid-actionbaractionbarsherlock

android:actionBarStyle requires API level 11


While using the ActionBarSherlock in xml at:

<item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>

I got this error:

android:actionBarStyle requires API level 11 (current min is 8) error

I'm using it for back porting my app with actionbar to 2.2 devices.

How to use them both together:

 <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
 <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>

Solution

  • You have to use only :

    <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item> 
    

    as you can get the error, you have android:actionBarStyle available at API level 11.


    If you want to be able to style your ActionBar to look the same in all API levels, you need to create different folders for the selected API level and create new style.xml/themes.xml files in these folders.

    For example:

    - res
      -- values
         -- styles.xml
         -- themes.xml // API LEVEL 8+
     -- values-v11
         -- styles.xml
         -- themes.xml // API LEVEL 11+
     -- values-v14
         -- styles.xml
         -- themes.xml // API LEVEL 14+
    

    The second thing which I can think of is be careful which themes are you including to your current one at different API Levels.

    For example, for API level 8: you will use @style/Theme.Sherlock.Light.DarkActionBar and you will have to use only actionBarStyle. While styling the action bar for API level 14+, you won't need actionBarStyle , because you probably will set Holo.Light theme as parent for your current one, so in this situation you will have to use android:actionBarStyle.