4

How could I change ActionBar color? I've implemeted this and it works but not as I want. it changes color only after activity started, so right after app launch the original bar colour is showed, and only a second later my custom color is dislpayed. Is there any other way to handle that? Thanks in advance

....
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);  
    ActionBar actionBar;
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#879f38")));
.....
Andrew Rahimov
  • 803
  • 2
  • 10
  • 18

1 Answers1

15

Create a Theme:

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

<style name="Theme.MyAppTheme.ActionBar" parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:background">#222222</item>
</style>
Ahmad
  • 69,608
  • 17
  • 111
  • 137
  • 1
    Eclipse throws an error `no resource found that matches the given name Widget.Holo.ActionBar ` What is wrong here? – Andrew Rahimov Apr 01 '13 at 18:20
  • 1
    @AvanJogia Oh sorry I left something out. I edited my answer. Check it out now. – Ahmad Apr 01 '13 at 18:26
  • In the same way, how can I change the action bar tab's underbar color to something different color instead of the default blue. – Karthick May 01 '13 at 06:21
  • @Ahmad hello sir..plz help me..i try this code but my app unfortunately stop..what i do????plz help me.. – Raja Priyan Jul 21 '15 at 04:32