0

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:

enter image description here

user3339562
  • 1,325
  • 4
  • 18
  • 34
  • I have possible one solution, but I don't think it will look good across all devices (this method "stretches" the picture so that it'll fit into the action bar) [link](http://stackoverflow.com/questions/8024706/how-do-i-change-the-background-color-of-the-actionbar-of-an-actionbaractivity-us) Go to this link on the left and use the first answer, but instead of inserting a random hex color code, you would instead use: @drawable/checkerboard_picture – Cherry Apr 08 '14 at 20:09

1 Answers1

1

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.

Community
  • 1
  • 1
Blo
  • 11,903
  • 5
  • 45
  • 99