Android beginner's journey (7) radiobutton Customization

Source: Internet
Author: User

If you want to use the radiogroup function, but encounter some seemingly simple problems that cannot be solved: The system icons are too big to be replaced, and you can find a solution on the Internet. As mentioned in some places, because images are used, they cannot be reduced, so we have to customize them. Refer to 1 for Reference 2.

Then, find the icon and search for files containing radio in the SDK folder. If there are many files, select a suitable one.

This is the radiobutton. xml file under Res/drawable.

<Selector xmlns: Android = "http://schemas.android.com/apk/res/android">
<Item
Android: state_enabled = "true"
Android: state_checked = "true"
Android: drawable = "@ drawable/check"/>
<Item
Android: state_enabled = "true"
Android: state_checked = "false"
Android: drawable = "@ drawable/checknull"/>
</Selector>

This is the definition of radiogroup. Note:

1. The radiogroup direction is horizontal. Android: Orientation = "horizontal ".

2. The button style is Android: button = "@ drawable/radiobutton ". It took a lot of effort to find this property.

<Radiogroup Android: Id = "@ + ID/radiogroup1" Android: paddingtop = "30px" Android: paddingleft = "15px" Android: Orientation = "horizontal" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content">
<Radiobutton Android: text = "today" Android: layout_width = "wrap_content" Android: textsize = "14px" Android: checked = "true" Android: layout_height = "wrap_content" Android: editable = "false" Android: Id = "@ + ID/radio0" Android: button = "@ drawable/radiobutton" Android: paddingleft = "30px" Android: layout_marginright = "2px" Android: textcolor = "#000"> </radiobutton>
<Radiobutton Android: text = "yesterday" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: Id = "@ + ID/radio1" Android: textsize = "14px" Android: button = "@ drawable/radiobutton" Android: paddingleft = "30px" Android: layout_marginright = "2px" Android: textcolor = "#000"> </radiobutton>
<Radiobutton Android: text = "the day before yesterday" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: Id = "@ + ID/Radio2" Android: textsize = "14px" Android: button = "@ drawable/radiobutton" Android: paddingleft = "30px" Android: layout_marginright = "2px" Android: textcolor = "#000"> </radiobutton>
</Radiogroup>

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.