Reputation: 1385
I was wondering is it possible to set a repeating picture as background of options menu instead of classical black color?
I would like to set something like this as my background:
Upvotes: 0
Views: 2203
Reputation: 11978
Create a drawable bitmap named menu_background.xml:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:tileMode="repeat"
android:src="@drawable/my_background_image" />
Then, custom your styles.xml as follows:
<style name="MyTheme" parent="@style/Theme.Holo.Light">
<item name="android:dropDownListViewStyle">@style/mListDropDown</item>
</style>
<style name="mListDropDown" parent="@style/Widget.Holo.Light.ListView.DropDown">
<item name="android:background">@drawable/menu_background"</item>
<item name="android:dividerHeight">...</item>
<item name="android:listSelector">...</item>
</style>
However, you will have many troubles to do the same for all devices - mainly the repeat mode: XML drawable Bitmap tileMode bug?. This bug is known and "partially fixed in Android 3.0 and completely fixed in ICS", see the comments on the accepted answer: "An easy workaround is to change the tiling mode from code". Also, you will able to achieve this on lower version with the panelFullBackground
attribute, see this example: How can I change the Options menu background for Android 2.3?.
I think that it's as heavy as useless. You will waste a lot of time to do it. Maybe you should reconsider your design by using a 9-patch drawable or the default android design. I hope this will be helpful.
Upvotes: 1