2014/08/17

[Android][XML]ActionBarの背景色を変更

AndroidManifest.xmlのapplicationタグのthemeが下の場合

<application
android:theme="@style/AppTheme" >
</application>
style.xml
<resources>
    <!-- ActionBar styles -->
    <style name="MainActionBar"
           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>
    
    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->

         <item name="android:actionBarStyle">@style/MainActionBar</item>
         <!-- Support library compatibility -->
         <item name="actionBarStyle">@style/MainActionBar</item>
        
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>
    
</resources>
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item name="actionbar_background" type="color">#FF0000</item>
</resources>

0 コメント:

コメントを投稿