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: