0

I have a style file where i am setting some action bar style like this

<style name="ActionBar.Solid.Pro" parent="@style/Widget.Sherlock.ActionBar.Solid">
        <item name="background">@color/dialer_color</item>
        <item name="backgroundStacked">@color/dialer_color</item>
        <item name="backgroundSplit">@color/dialer_color</item>
        <item name="android:progressBarStyle">@style/ProgressBar.Pro</item>
    </style>

Now i want to change the color of action bar programmatically like this`

getSupportActionBar.setBackgroundDrawable(new ColorDrawable(Color.Red));

But it do not have any effect. Can you please tell me why , where i am doing wrong

Is it possible to change the ActionBar.TabView background programatically ? I am setting my style like this, how can i change the background of this style attribute ?

 <style name="ActionBarTabStyle.Pro" parent="@style/Widget.Sherlock.ActionBar.TabView">
    <item name="android:background">@color/dialer_color</item>
</style>
Bora
  • 1,933
  • 3
  • 28
  • 54

2 Answers2

0

See you can refer to android action bar style generator That makes the work of customising the action bar much easier I advice you that you must have a look on this link It will surely help you

http://jgilfelt.github.io/android-actionbarstylegenerator/#name=example&compat=holo&theme=light&actionbarstyle=solid&texture=0&hairline=0&neutralPressed=1&backColor=E4E4E4%2C100&secondaryColor=D6D6D6%2C100&tabColor=33B5E5%2C100&tertiaryColor=F2F2F2%2C100&accentColor=33B5E5%2C100&cabBackColor=FFFFFF%2C100&cabHighlightColor=33B5E5%2C100

And one more thing when you will be done with specifying the colors then you will receive the set of images in an archive i.e. .zip format So you must extract them in their respective folders or directories In the directory naming "res"

Priyank
  • 37
  • 1
  • 7
0

My suggestion is to drop the ActionBar alltogether and use the new Toolbar from the AppCompatLibrary V21. There you just specify Primary and Accent Colors and your background will be set, as well as all controls on it.

For starters this is described in the blog from Chris Banes:

appcompat v21: material design for pre-Lollipop devices!

  • You don't have to drop the ActionBar altogether. You just need to use the `Theme.AppCompat` and then you can make use of the new attributes. – reVerse Oct 20 '14 at 09:20
  • is there any way to change background of this style attribute programatically @style/Widget.Sherlock.ActionBar.TabView – Bora Oct 20 '14 at 09:22
  • @reVerse Changing from ActionBar to AppCompat Toolbar is a smart move in my opinion because you will also get Material Design toolbars out of it. – Jürgen 'Kashban' Wahlmann Oct 20 '14 at 12:02