您的位置:首页 > 其它

按钮被按时候切换图片

2016-02-27 15:16 218 查看
在res/drawble文件下新建一个button_checked.XML文件

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/quick_menu_select" android:state_checked="true"></item>
<item android:drawable="@drawable/tab_more" android:state_pressed="true"/>
<item android:drawable="@drawable/quick_menu_unselect" ></item>
</selector>

然后在button中使用这个文件
<RadioButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="@drawable/button_checked" />

android:state_checked  被选中后所显示的图片
android:state_pressed 被按住时候所显示的图片
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: