Thursday, October 24, 2013

Android Development: To change the titlebar background color

Notes:

    the color setted was light gray
    For <api 11, the attribute changed was windowTitleBackgroundStyle
    For >api 11, actionBarStyle


Add to the application tag, on AndroidManifest.xml:

android:theme="@style/ThemeSelector"

On values/styles.xml, it was added:

    <style name="ThemeSelector" parent="android:Theme.Light">
        <item name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground</item>
    </style>

    <style name="WindowTitleBackground">   
        <item name="android:background">#E0E0E0</item>
    </style>


On values-v11/styles.xml, add:

    <style name="ThemeSelector" parent="android:Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/ActionBar</item>
    </style>

    <style name="ActionBar" parent="android:style/Widget.Holo.ActionBar">   
        <item name="android:background">#E0E0E0</item>
    </style>

No comments:

Post a Comment