Android Custom checkbox Style

Source: Internet
Author: User

Most of the time, we don't use the checkbox style of the android comes with our UI, so we need to customize our checkbox.


First look for two checkbox background images, like:



Then, in the Drawable directory, define a background image XML file with the following content:

<?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/fuxuan_input01 "/>    < Item android:state_selected= "True" android:drawable= "@drawable/fuxuan_input01" ></item>    <item Android:state_pressed= "true" android:drawable= "@drawable/fuxuan_input01" ></item>    <item android: State_checked= "false" android:drawable= "@drawable/fuxuan_input02"/></selector>


Define it where you want to use the checkbox, as shown in the following code:

        <checkbox            android:id= "@+id/agree_provision_chk"            android:layout_width= "Wrap_content"            android: layout_height= "Wrap_content"            android:background= "@drawable/chk_agee_provision_background"            android: button= "@null"/>

This completes the custom checkbox, as shown in the following:


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android Custom checkbox Style

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.