Search code examples
androidandroid-actionbarandroid-tabsandroid-styles

ActionBar and ActionBar Tabs are pure white


How can we make action bar and action bar tabs pure white. I am using android-support-v7-appcompat libs to support backward compatibility. style/Theme.AppCompat.Light.DarkActionBar gives pure black but style/Theme.AppCompat.Light does not give pure white.


Solution

  • There is no default theme that would give a white action bar. You will need to make a customized action bar for your app.

    The developer docs has a good article about customizing the action bar.

    https://developer.android.com/training/basics/actionbar/styling.html

    These are the custom styles that you will need to alter.

    res/values/themes.xml

    See the android:background tag where you can set a drawable for the action bar.

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <!-- the theme applied to the application or activity -->
        <style name="CustomActionBarTheme"
               parent="@style/Theme.Holo.Light.DarkActionBar">
            <item name="android:actionBarStyle">@style/MyActionBar</item>
        </style>
    
        <!-- ActionBar styles -->
        <style name="MyActionBar"
               parent="@style/Widget.Holo.Light.ActionBar.Solid.Inverse">
            <item name="android:background">@drawable/actionbar_background</item>
        </style>
    </resources>
    

    Apply the theme to your app.

    <application android:theme="@style/CustomActionBarTheme" ... />