Actionbarスタイルのカスタマイズ

1980 ワード

備考:Theme.Holo.xxxのテーマの下でTabBar Tab項目は、タイトルのみ表示でき、指定された画像は表示できません.「Theme.Black」または「Theme.Light」に変更できます.
以下は転載です.
1)、res/values/stylesディレクトリではTheme.Sherlock.LightDarkActionBarを使用          カスタマイズする場合は、actionBarStyleを上書きするだけです.
<style name="AppBaseTheme" parent="Theme.Sherlock.Light.DarkActionBar"></style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    <item name="actionBarStyle">@style/MyActionBarStyle</item>
</style>
    
<style name="MyActionBarStyle" parent="@style/Widget.Sherlock.Light.ActionBar.Solid.Inverse">
    <item name="background">@drawable/ab_custom_blue_holo_light</item>
</style>

もちろん、対応するフォントの色、アイコンの色、メニューのスタイルなどは、それほど調和がとれていない可能性があります.これは、フォントの色、アイコンの普通のスタイル、押したスタイルなど、いくつかの他のスタイルを上書きする必要があります.  
    2)、res/values-14/styles.xmlでは、システム定義を上書きするだけです.
<!--
        Base application theme for API 14+. This theme completely replaces
        AppBaseTheme from BOTH res/values/styles.xml and
        res/values-v11/styles.xml on API 14+ devices.
    -->
    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">

        <!-- API 14 theme customizations can go here. -->
        <item name="android:actionBarStyle">@style/MyActionBarStyle</item>
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme"></style>

    <style name="MyActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">@drawable/ab_custom_blue_holo_light</item>
    </style>