Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change ActionBar color? [duplicate]

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")));
.....
like image 625
Andrew Rahimov Avatar asked Dec 06 '22 08:12

Andrew Rahimov


1 Answers

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>
like image 110
Ahmad Avatar answered Dec 08 '22 22:12

Ahmad