这是按钮:
<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
属性时无法实现,因为android:background
已用于背景图片。请帮忙解决这个问题。
答案 0 :(得分: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" />
答案 1 :(得分: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>