Android – ActionBar background image

androidandroid-3.0-honeycombandroid-actionbar

I've inherited the Holo Light Theme and customized the background of the ActionBar with the following:

Content of styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="ActionBar" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:background">@drawable/actionbar_background</item>
</style>
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/ActionBar</item>
</style>
</resources>

Content of actionbar_background.xml

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@raw/actionbar_background"
android:tileMode="repeat" />

Instead of being repeated, the image is stretched, any idea of why android:tileMode="repeat" is not applied?

Thanks in advance

Best Answer

Drawable d=getResources().getDrawable(R.drawable.background_image_name);  
getActionBar().setBackgroundDrawable(d);

The above code sets the background image for the action bar.
Hope it helps.

Related Topic