Android:Actionbarstyle Requires API Level 11

android:actionBarStyle requires API level 11

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.

Android AppCompat requires API level 11

Add the below in styles.xml under res/values-14

<style name="Theme.Styled" parent="@style/Theme.AppCompat.Light">
<!-- Setting values in the android namespace affects API levels 14+ -->
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>

</style>

<style name="Widget.Styled.ActionBar" parent="@style/Widget.AppCompat.Light.ActionBar">
<!-- Setting values in the android namespace affects API levels 14+ -->
<item name="android:background">#FFFFFF</item>

</style>

You would then need add the following into the values folder: res/values/styles.xml

<style name="Theme.Styled" parent="@style/Theme.AppCompat.Light">
<!-- Setting values in the default namespace affects API levels 7-13 -->
<item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
</style>

<style name="Widget.Styled.ActionBar" parent="@style/Widget.AppCompat.Light.ActionBar">
<!-- Setting values in the default namespace affects API levels 7-13 -->
<item name="background">#FFFFFF</item>
</style>

For more details

http://android-developers.blogspot.in/2013/08/actionbarcompat-and-io-2013-app-source.html

Notice the change for API level 14+

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

To API level 7-13

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

android:windowActionBarOverlay & android:actionBarStyle requires api level 11

Found solution to my problem :

I have to make separate styles.xml in res/values-v11 to support the same functionality in android 3.0 and up

Theming ActionBarSherlock gives api level error

I tried restarting, but I ultimately needed to clean the project: Click "Project->Clean..."

The error came back every time I saved my styles.xml. For now, I am setting my minimum API level to 11 temporarily while editing that file to avoid the errors, and then resetting it back down and cleaning when I want to run it on my low-API-level emulator.

Edit: If you don't like leaving your min SDK version artificially high, it also works for me to change it to 14 (some other high number), save AndroidManifest.xml, change it right back, and save again.

android:actionBarStyle requires API level 11

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.

Applying a theme to v7 Support Action Bar

You need to provide two API specific styles.xml. In your values/styles.xml use

<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">@style/ActionBarTheme</item>
</style>

and in your values-v14/styles.xml use

<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/ActionBarTheme</item>
</style>

Sherlock : android:textAllCaps requires API level 14 (current min is 8)

just add the style to a style-v14 folder and another without this value on the normal style folder.

How to change color of ActionBar's Title Text on Android 4.3 api 18

Found Solution to my own problem :

I have to use android:actionBarStyle , android:titleTextStyle and android:textColor for api level 14 and up.

So the styles.xml for v-11 will be:

<resources>

<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/ActionBarStyle</item>
</style>

<style name="ActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="android:titleTextStyle">@style/TitleBarTextColor</item>
</style>

<style name="TitleBarTextColor" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/red</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

</resources>

Views and atributtes from android layout

Yes, there are some attributes that require a min API, take a look at this:
android:actionBarStyle requires API level 11

if it does and your min API level (in your build.gradle) is too low then android will tell you.



Related Topics



Leave a reply



Submit