"Go" Android Learning basic Custom checkbox component

Source: Internet
Author: User

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

    1. <?xml version= "1.0" encoding= "Utf-8"?>
    2. <selector xmlns:android= "Http://schemas.android.com/apk/res/android" >
    3. <item android:state_checked= "true" android:drawable= "@drawable/checked" ></item>
    4. <item android:state_checked= "false" android:drawable= "@drawable/unchecked" ></item>
    5. <item android:drawable= "@drawable/unchecked" ></item><!--The default one--and
    6. </selector>
Copy Code



Android Development App Customization

Set the Button property value to the Custom_checkbox defined above.

    1. <checkbox
    2. Android:layout_width= "Wrap_content"
    3. android:layout_height= "Wrap_content"
    4. android:button= "@drawable/custom_checkbox"
    5. />
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.