Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change action bar color in android

I am using the app theme Theme.Black in my app. In this theme the action bar is gray. How I can change color of my action bar? This is my attempt:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="mytheme" parent="@android:style/Theme.Black" >

    </style>
    <style name="Widget.MyApp.ActionBar" parent="@android:style/Widget.ActionBar">
        <item name="android:background">@android:color/black</item>
    </style>



</resources>

However, it doesn't work. Any ideas?

like image 913
user1302569 Avatar asked Aug 13 '12 08:08

user1302569


People also ask

How can I customize my action bar in Android?

This example demonstrate about how to create a custom action bar in Android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.

How do I change the color of my toolbar title?

Option 1) The quick and easy way (Toolbar only)setTitleTextColor(Color. WHITE); toolbar. setSubtitleTextColor(Color. WHITE);

How do I change the text color on my Android toolbar?

Go to the app > res > values > themes > themes. xml file and add the following line inside the <resources> tag. In the activity's onCreate() method, call the activity's setSupportActionBar() method, and pass the activity's toolbar.


Video Answer


1 Answers

ActionBar bar = getActionBar();
bar.setBackgroundDrawable(new ColorDrawable("COLOR")); 

it worked for me here

like image 193
user3225831 Avatar answered Sep 28 '22 07:09

user3225831