Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing background android title bar

I know this question has already been asked, but I can't figure out how to get it working. I want to change the background of my title bar.

I don't want to change anything else about the style of my application or of my background.

I followed various post on this site, but none of them seem to give a satisfying result.

I would think it would be as simple as setting

<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowTitleBackgroundStyle">@drawable/backrepeat</item>
</style>

In styles.xml

However this gives no change whatsover.

For completness below is my backrepeat file

<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/bg_diamonds"
android:tileMode="repeat"
android:dither="true" 
/>

and the code in manifest.xml

<application
android:allowBackup="true"
android:icon="@drawable/maxmm_start_icon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
like image 727
Tim van Lieshout Avatar asked Oct 01 '13 09:10

Tim van Lieshout


People also ask

How can I change the color of my title bar in Android?

Just go to res/values/styles.edit the xml file to change the color of action bar.

How can I change status bar background in Android?

Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar.

How do I change app bar title?

Here's how you do it: Step 1: Locate the file where you have placed the AppBar widget. Step 2: Inside the AppBar widget, find the Text widget inside the title parameter. Step 3: Inside the Text widget, add the style parameter and add the TextStyle widget.


2 Answers

You can use it when activity created. (onCreate)

ActionBar bar = getActionBar();
//for color
bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00C4CD")));
//for image
bar.setBackgroundDrawable(getResources().getDrawable(R.drawable.settings_icon));
like image 108
Melih Mucuk Avatar answered Sep 20 '22 08:09

Melih Mucuk


You can change your title color using this code add these line in oncreate() :

ColorDrawable colorDrawable = new ColorDrawable(Color.parseColor("#20a780"));
    getSupportActionBar().setBackgroundDrawable(colorDrawable);
like image 25
Aneh Thakur Avatar answered Sep 23 '22 08:09

Aneh Thakur