アクションバーの動作は、API<11でも変更できます。
参考のためにAndroidの公式ドキュメントを参照してください
でアプリを作成してminSdkVersion = "9"
いtargetSdkVersion = "21"
ますが、アクションバーの色を変更しましたが、APIレベル9で正常に動作します
これがxmlです
res/values/themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">@color/actionbar_background</item>
<!-- Support library compatibility -->
<item name="background">@color/actionbar_background</item>
</style>
</resources>
必要なアクションバーの色を設定します
res/values/colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="actionbar_background">#fff</color> //write the color you want here
</resources>
アクションバーの色は.class
ファイルで定義することもできます。スニペットは
ActionBar bar = getActionBar();
bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#0000ff")));
ただし、これはAPI <11では機能しないため、アクションバーのスタイル設定はxml
API<11の唯一の方法です。