Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Applying a theme to v7 Support Action Bar

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

<?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 in the actionBarStyle line. The error is this one:

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

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

like image 841
Charlie-Blake Avatar asked Aug 19 '13 06:08

Charlie-Blake


1 Answers

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>
like image 83
hitmaneidos Avatar answered Sep 20 '22 23:09

hitmaneidos