Android advanced UI deep customization series (2)
Radiobutton also serves as a tab.
:
XML layout:
< Radiogroup Android: ID = "@ + ID/radiogroup1" Android: layout_width = "Match_parent" Android: layout_height = "Wrap_content" Android: Orientation = "Horizontal" > < Radiobutton Android: ID = "@ + ID/radio0" Android: layout_width = "Match_parent" Android: layout_height = "Wrap_content" Android: layout_weight = "1" Android: Background = "@ Drawable/XXX" Android: button = "@ Drawable/NONE" Android: checked = "True" Android: drawabletop = "@ Drawable/yyy" Android: Text = "Radiobutton" /> < Radiobutton Android: ID = "@ + ID/radio1" Android: layout_width = "Match_parent" Android: layout_height = "Wrap_content" Android: layout_weight = "1" Android: Background = "@ Drawable/XXX" Android: button = "@ Drawable/NONE" Android: drawabletop = "@ Drawable/yyy" Android: Text = "Radiobutton" /> < Radiobutton Android: ID = "@ + ID/Radio2" Android: layout_width = "Match_parent" Android: layout_height = "Wrap_content" Android: layout_weight = "1" Android: Background = "@ Drawable/XXX" Android: button = "@ Drawable/NONE" Android: drawabletop = "@ Drawable/yyy" Android: Text = "Radiobutton" /> </ Radiogroup >
Important attributes:
Android: drawabletop, Android: button, Android: Background
as the ADT continues to upgrade, visual UI editing becomes more convenient and efficient. Through the properties panel, you can quickly query and set various attributes of the UI component.
radiobutton is a prerequisite for personalized customization. Android: drawabletop indicates the image resources in the upper part of the component, which is not available by default. Android: the button indicates the circle radio we usually see, which is a drawable resource instead of a button ID. Android: Background certainly indicates the background image of the entire radiobtton.
in order for the three radiobutton to evenly occupy the screen width, set layout_width to match_parent and set their layout_weight to the same priority when assigning the width.
advantages:
the selected status is maintained to achieve different visual effects. The common practice is to change the effect only when you click or touch the screen. In this example, the effect is solidified, the checked attribute of radiobutton is used