[android]代码库
1.例子--按下按钮,切换图片
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:state_pressed="true"
android:drawable="@drawable/c"
></item>
<item
android:drawable="@drawable/a"
></item>
</selector>
2.例子--按下按钮,切换字体颜色
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:state_pressed="true"
android:color="#ffff00" //按下的颜色
></item>
<item
android:color="#000000" //默认的颜色
></item>
</selector>
main.xml中
android:textColor="@drawable/myselector"
by: 发表于:2017-09-29 14:55:51 顶(0) | 踩(0) 回复
??
回复评论