Search code examples
androidcolorsandroid-actionbarandroid-appcompatandroid-actionbar-compat

custom action Bar color with appcompat for api 7


I wanna to use custom colors for the action Bar for api 7

But i have problem:

@android:style/Widget.Holo.Light.ActionBar requires api 11 (current min is 7)

How can I do that with API 7?


Solution

  • You can use AppCompat v21.

    You can define your default style in res/values/styles.xml

    <style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
    
        <!-- Set AppCompat’s color theming attrs -->
        <item name="colorPrimary">@color/my_color</item>
    </style>
    

    If you would like to customize the color for API-V7 you can define a different style in res/values-v7/styles.xml with the same structure:

         <style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
    
            <!-- Set AppCompat’s color theming attrs -->
            <item name="colorPrimary">@color/my_v7_color</item>
        </style>
    

    I suggest you checking the current distribution of Android. API 7 doesn't exist.