1.在目录res/Drawable下新增一个xml文件,文件名字为definecheckbox.xml
android:drawable="@drawable/android" />
android:drawable="@drawable/ios" />
2.在strings.xml增加一个style标签
Hello World, TestQActivity!
TestQ
@drawable/checkdefine
3.布局文件main.xml中CheckBox属性设置
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/defineCheckBox"
/>
运行效果:
点击选中之后的效果如下:
感觉意义不是很大,效果和Button切换背景差不多~