-1

Here is my xml code in styles.xml to change theme and colour of ActionBar.

<?xml version="1.0" encoding="utf-8"?>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>

<!-- ActionBar styles -->
<style name="MyActionBar"
    parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:icon">@drawable/brand_logo</item>
    <item name="android:background">#ff5d44</item>
</style>

Here is the documentation. My app supports API level 11 and higher. Not sure where I am going wrong. Please help.

Neanderthal
  • 937
  • 2
  • 9
  • 25

2 Answers2

1

set "AppTheme" as theme for application / activity.

 <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@android:color/white</item>

</style>

For more check THIS ,THIS and THIS

Community
  • 1
  • 1
Anirudh Sharma
  • 7,968
  • 13
  • 40
  • 42
0

I was using support library. So here is the fix.

<style name="MyActionBar"
        parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="android:background">#ff5d44</item>
        <item name="android:titleTextStyle">@style/MyActionBarTitleText</item>

         <!--Support library compatibility-->
        <item name="background">@color/orange</item>
        <item name="titleTextStyle">@style/MyActionBarTitleText</item>
    </style>
Neanderthal
  • 937
  • 2
  • 9
  • 25
  • It is quite curious that you write a question about the background color of the actionbar, and you check as correct a your answer that is not the best answer. The current appCompat (v21) uses the answer reported by @Anirudh. – Gabriele Mariotti Apr 04 '15 at 13:25