• 0
Votes
name
name Punditsdkoslkdosdkoskdo

Where is a reference to the android XML UI layout?

I am looking for a spec or reference of all the possible options for the various XML layout attribute settings that typically come with an android UI. Google seem to be good at burying it. 

Such as what are my options available to me for the TextView layout_width definition ? There must be a complete definition published ... somehwere....

layout_* attributes aren't directly part of the view they appear on, which is why you won't find them in TextView's documentation. (TextView is not a ViewGroup.) They are arguments to the parent view, also known as LayoutParams. Take a look at the "Known Subclasses" sections at the top of the linked page for a list of them. They're instructions about how a ViewGroup should arrange each child view, and each parent type can recognize different ones depending on what kinds of layout options it supports.

For example, LinearLayout.LayoutParams supports the android:layout_weight parameter. Children of a LinearLayout can specify weight to request a proportion of the remaining space after all children have been measured. You can give equal weight to two sibling TextViews with a base width of 0 to give them each half of the available space within the parent.

< LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal">
    < TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:text="Hello">
    < TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:text="World">
< /LinearLayout>
  • 1
Reply Report