0

这是按钮:

<Button
        android:id="@+id/button1"
        android:layout_width="250dp"
        android:layout_height="75dp"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="39dp"
        android:background="@drawable/sam_back" />

使用selector属性时无法实现,因为 asandroid:background已用于背景图像。请帮助解决这个问题。

4

2 回答 2

0
    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_pressed="true" android:drawable="@color/gray"/> <!-- pressed -->
        <item android:state_focused="true" android:drawable="@color/gray"/> <!-- focused -->
        <item android:drawable="@drawable/edittext_backround"/> <!-- default -->
    </selector>

1.make one xml with name buttonselector.xml
2.then set backround like this ..  android:background="@drawable/buttonselector" />
于 2013-10-29T12:41:26.843 回答
0
 <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@drawable/hover_btn" android:state_pressed="true"/>
<item android:drawable="@drawable/btn"/>

</selector>
于 2013-10-29T12:42:08.050 回答