android开发教程之自定义控件checkbox的样式示例
puma 故乡,发誓歌词,麻城论坛
主界面xml文件
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<checkbox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/check_selector"
android:checked="true" />
</relativelayout>
/res/drawable-hdpi/check_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/checkok" android:state_checked="true"></item>
<item android:drawable="@drawable/checkno" android:state_checked="false"></item>
</selector>
p.s:重点: android:button="@drawable/check_selector"
check_selector.xml中的checkok为checkbox选中状态的图片,checkno为checkbox未选中状态的图片.
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!!
点击进行留言回复
网友评论