Android ApiDemos example resolution (105): Views-& gt; Buttons

Source: Internet
Author: User

The Buttons example describes how to define a Button and a ToggleButton. In this example, the definition of/res/layout/buttons_1.xml is as follows:

<! -Regular sized buttons->
<Button android: id = "@ + id/button_normal"
Android: text = "@ string/buttons_0000normal"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"/>

<! -Small buttons->
<Button android: id = "@ + id/button_small"
Style = "? Android: attr/buttonStyleSmall"
Android: text = "@ string/buttons_javassmall"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"/>

<ToggleButton android: id = "@ + id/button_toggle"
Android: text = "@ string/buttons_javastoggle"
Android: textOn = "Open"
Android: textOff = "Close"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"/>

When a button is defined and no style is specified, Android displays the Button in normal size,

Style? Android: attr/buttonStyleSmall: display the Button in a compact style.

When referencing the Style property value, use "?" Instead of "@" to specify the required style attributes. The format is as follows:

? [<Package_name >:] [<resource_type>/] <resource_name>

The resource_type part is optional. Therefore, the following definitions can be used in this example:

Style = "? Android: buttonStyleSmall"

ToggleButton uses the button form to define two states, such as Open and Close. The default text is ON and OFF. You can use the attributes textOn and textOff to redefine the text.

 

 
 


Related Article

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.