Original URL: http://forum.maiziedu.com/thread-515-1-1.html
The Heckbox component is a basic control that can select multiple items at the same time, that is, check box, in Android Learning, the checkbox is a very important UI component, because its presentation of aesthetics and coordination does not meet our needs, we need to customize this component, the method is simple, Just add the modifications to the XML file.
First you need to prepare two pictures, one is the selected picture, one is an unselected picture.
Android Development Settings Selection box
Create a new file under Drawable custom_checkbox.xml
- <?xml version= "1.0" encoding= "Utf-8"?>
- <selector xmlns:android= "Http://schemas.android.com/apk/res/android" >
- <item android:state_checked= "true" android:drawable= "@drawable/checked" ></item>
- <item android:state_checked= "false" android:drawable= "@drawable/unchecked" ></item>
- <item android:drawable= "@drawable/unchecked" ></item><!--The default one--and
- </selector>
Copy Code
Android Development App Customization
Set the Button property value to the Custom_checkbox defined above.
- <checkbox
- Android:layout_width= "Wrap_content"
- android:layout_height= "Wrap_content"
- android:button= "@drawable/custom_checkbox"
- />
Copy Code
The above implementation of the checkbox component customization, interested users can run to see the results.
"Go" Android Learning basic Custom checkbox component