layout_* attributes are not directly part of the view on which they are displayed, so you will not find them in the TextView 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 page listing them. These are instructions on how the ViewGroup should arrange each child view, and each parent type can recognize different depending on what layout options it supports.
For example, LinearLayout.LayoutParams supports the android:layout_weight . LinearLayout can specify a weight to request a fraction of the remaining space after all children have been measured. You can give equal weight to two TextViews with a base width of 0 to give them every half of the available space inside 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>
source share