This example uses LinearLayout to construct an input form and layout_gravity pairs to deploy the button display position.
LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Android: orientation = "vertical"
Android: background = "@ drawable/blue"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: padding = "10dip">
<! -
TextView goes on top...
->
<TextView
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: text = "@ string/linear_layout_5_instructions"/>
<! -
Followed by the EditText field...
Also give it a standard background (the "android :"
Part in @ android: drawable/editbox_background
Means it is system resource rather
An application resource.
->
<EditText
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: background = "@ android: drawable/editbox_background"/>
<! -
Use a horizontal layout to hold the two buttons.
This item has layout_gravity = "right". This means the whole
Horizontal LinearLayout is right aligned, not the individual
Items within it. The horizontal LinearLayout's width is set
Wrap_content. (If it was match_parent it wocould not have any
Room to slide to the right .)
->
<LinearLayout
Android: orientation = "horizontal"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_gravity = "right">
<Button
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: text = "@ string/linear_layout_5_cancel"/>
<Button
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_marginLeft = "10dip"
Android: text = "@ string/linear_layout_5_ OK"/>
</LinearLayout>
</LinearLayout>