Applying a theme to the v7 support dashboard

I am using the v7 support library to implement an ActionBar in my application. I have this in the styles.xml

 <?xml version="1.0" encoding="utf-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar"> <item name="android:actionBarStyle">@style/ActionBarTheme</item> </style> <style name="ActionBarTheme" parent="android:Widget.ActionBar"> <item name="android:background">#FFFF0000</item> </style> </resources> 

However, Eclipse complains about the actionBarStyle string. The error is as follows:

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

What can I do to apply my theme to API levels 8-10?

+6
source share
2 answers

You need to provide two styles.xml API styles. In your /styles.xml values ​​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> 
+11
source

If you are using the latest v7 support library (v21 at the time of publication), there is no need to add the android: prefix to any action bar attributes.

In your case, just add the following to values/styles.xml :

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

Link: https://chris.banes.me/2014/10/17/appcompat-v21/#migration-from-previous-setup

0
source

Source: https://habr.com/ru/post/951997/


All Articles