1.设置字体变色
selector_orange_white.xml
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!--黑白字体颜色切换 默认是黑 点击之后是白--> <item android:color="@color/oranger" android:state_pressed="false" android:state_enabled="true"/> <item android:color="@color/white" android:state_pressed="true" android:state_enabled="true"/> <item android:color="@color/invaild" android:state_enabled="false"/>" </selector>
2.设置背景变化
selector_highlight_button.xml
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_pressed="false" android:drawable="@drawable/shape_button_highlight"/> <item android:state_pressed="true" android:drawable="@drawable/shape_button_highlight_clicked"/> </selector>
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <stroke android:width="1dp" android:color="#ff8500" /> <solid android:color="@color/white" /> <padding android:bottom="1dp" android:left="1dp" android:right="1dp" android:top="1dp" > </padding> </shape>
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <stroke android:width="1dp" android:color="#ff8500" /> <solid android:color="#ffb055" /> <padding android:bottom="1dp" android:left="1dp" android:right="1dp" android:top="1dp" > </padding> </shape>
android:background="@drawable/selector_highlight_button"
android:textColor="@color/selector_orange_white"