Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android AppCompat requires API level 11

I have an app that uses the AppCompat support libary for ActionBars. Now I tried to create a new themes.xml file with some style for that purpose.

<!-- Application theme. -->
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="actionBarStyle">@style/MyActionBar</item>
</style>

So just the same way it is done here: http://developer.android.com/guide/topics/ui/actionbar.html#StyleExample However, Eclipse throws an error here and says:

android:actionBarStyle requires API level 11 (current min is 8) themes.xml

How can this be as I am using the support libary?

like image 983
benestar Avatar asked Nov 17 '13 14:11

benestar


1 Answers

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>
like image 133
Raghunandan Avatar answered Oct 10 '22 17:10

Raghunandan