Change android header background

I know this question has already been asked, but I cannot figure out how to make it work. I want to change the background of my title bar.

I do not want to change anything about the style of my application or my background.

I followed a few posts on this site, but none of them seem to give a satisfactory result.

I would have thought it would be as easy as installing

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

In styles.xml

However, this does not give any changes.

For completeness below 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 code in manifest.xml

 <application android:allowBackup="true" android:icon="@drawable/maxmm_start_icon" android:label="@string/app_name" android:theme="@style/AppTheme" > 
+7
android titlebar custom-titlebar
source share
2 answers

You can use it when creating an action. (OnCreate)

 ActionBar bar = getActionBar(); //for color bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00C4CD"))); //for image bar.setBackgroundDrawable(getResources().getDrawable(R.drawable.settings_icon)); 
+23
source share

You can change the color of the header using this code, add this line to oncreate ():

 ColorDrawable colorDrawable = new ColorDrawable(Color.parseColor("#20a780")); getSupportActionBar().setBackgroundDrawable(colorDrawable); 
+10
source share

All Articles