Android ApiDemos example resolution (150): Views-& gt; Layouts-& gt; Line

Source: Internet
Author: User

Previous: http://www.bkjia.com/kf/201209/152591.html

LinearLayout can be used to construct a group of several related UI spaces and set android: addStatesFromChildren to True. In this way, when EditText or Button in the group gets the Focus, set the BackgroundImage of Layout to the Drawable of the corresponding EditText or Button (press to get the Focus). In this case, the drawable status of Layout and the display effect of its subedittext or Button are as follows, the View in Layout is a whole.

<LinearLayout
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: addStatesFromChildren = "true"
Android: gravity = "center_vertical"
Android: paddingRight = "0dip"
Android: background = "@ android: drawable/edit_text">

<! -
TextView label goes at the left.
->
<TextView
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: text = "@ string/linear_layout_10_to"
Android: textColor = "? Android: attr/textColorSecondary"
Android: textAppearance = "? Android: attr/textAppearanceLargeInverse"
/>

<! -
EditText goes in.
->
<EditText
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_weight = "1 ″
Android: singleLine = "true"
Android: background = "@ null"
/> Www.2cto.com

<! -
The button goes at the right.
->
<ImageButton
Style = "@ android: style/Widget. Button. Inset"
Android: src = "@ android: drawable/star_big_on"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_marginTop = "2dip"
Android: layout_marginRight = "2dip"
Android: layout_marginBottom = "2dip"
Android: padding = "10dip"
/>

</LinearLayout>

In this example, LinearLayout neutron ViewEditText can get the focus, set the background of LinearLayout to the drawable of @ android: Drawable/edit_text and EditText, and android: addStatesFromChildren = "true ", in this way, when EditText gets the focus, the display effect is the focus of the entire Layout. The three sub-Views seem to be a whole:

 

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.