0

Possible Duplicate:
how to set image button backgroundimage for different state?

I have the following declaring how a button should be drawn (uabutton.xml):

<?xml version="1.0" encoding="UTF-8"?>
<selector
    xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_pressed="true" >
        <shape>
            <corners
                android:radius="3dp" />
            <gradient
                android:startColor="#000000"
                android:endColor="#e9e8e9"
                android:angle="270" />
        </shape>
    </item>

    <item android:state_focused="true" >
        <shape>
            <corners
                android:radius="3dp" />
            <gradient
                android:endColor="#ffffff"
                android:startColor="#b9b9b9"
                android:angle="270" />
        </shape>
    </item>

    <item android:state_enabled="false">
        <shape>
            <corners
                android:radius="3dp" />
            <gradient
                android:startColor="#f0aa9f"
                android:endColor="#e21f00"
                android:angle="270" />
        </shape>
    </item>

    <item>        
        <shape>
            <corners
                android:radius="3dp" />
            <gradient
                android:startColor="#ff8a0e"
                android:endColor="#e9e8e9"
                android:angle="270" />
        </shape>    
    </item>
</selector>

My question is, I would like to add an image to the background of each button. Where, if anywhere, in the above would I add the image.

The button is added a to a RelativeLayout:

<Button
    android:id="@+id/aboutualocationbtn"
    android:text="Menu"
    android:layout_width="60dp"
    android:layout_height="60dp"
    android:background="@drawable/uabutton"/>
Community
  • 1
  • 1
Mike D
  • 4,938
  • 6
  • 43
  • 99

2 Answers2

1

Wrap it in a Layer List drawable.

Dan S
  • 9,139
  • 3
  • 37
  • 48
0
android:background="@drawable/uabutton"

is pointing to a file called uabutton in your drawables folder as the background

ie uabutton.jpg or uabutton.png

Herb
  • 345
  • 1
  • 17
  • I know that. I need that file to for the gradients and shape of the buttons. I need to add a small subtle image to the button also. – Mike D Oct 20 '11 at 14:57