<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<item android:drawable="@drawable/orange_bg" android:state_pressed="true"/>
<item android:drawable="@drawable/ashend_bg" />
</selector>
在这个下面,selector下面设置了item标签,android:drawable="@drawable/orange_bg",设置颜色必须这样设置,在drawable下面设置shape来完成颜色样式的设置。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<corners android:radius="5dp"/>
<solid android:color="#ffff00"/>
</shape>
比如这里的方法。