Android ApiDemos示例解析(139):Views->Layouts->Baseline->Nested Example 2
2012-08-25 09:38
363 查看
本例和上例类似,只是将其中一个子LinearLayout的orientation从vertical 改成horizontal,同样去掉android:layout_gravity=”center_vertical”
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:orientation=”horizontal”
android:layout_width=”match_parent”
android:layout_height=”match_parent”>
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_marginRight=”3dip”
android:text=”@string/baseline_nested_1_label” />
<!– We want the middle textview of this vertical linear layout to
be baseline aligned with the others.–>
<LinearLayout
android:orientation=”vertical”
android:baselineAlignedChildIndex=”1″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
>
<ImageView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/arrow_up_float”/>
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_marginRight=”5dip”
android:text=”@string/baseline_nested_1_label” />
<ImageView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/arrow_down_float”/>
</LinearLayout>
<!– We want the third index textview of this vertical linear layout to
be baseline aligned with the others.–>
<LinearLayout
android:orientation=”horizontal”
android:baselineAlignedChildIndex=”2″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”>
<ImageView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/arrow_up_float”/>
<ImageView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/arrow_up_float”/>
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_marginRight=”5dip”
android:text=”@string/baseline_nested_1_label” />
</LinearLayout>
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:textSize=”20sp”
android:text=”@string/baseline_nested_1_label” />
</LinearLayout>
![](http://www.imobilebbs.com/wordpress/wp-content/uploads/2011/07/20110708002.png)
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:orientation=”horizontal”
android:layout_width=”match_parent”
android:layout_height=”match_parent”>
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_marginRight=”3dip”
android:text=”@string/baseline_nested_1_label” />
<!– We want the middle textview of this vertical linear layout to
be baseline aligned with the others.–>
<LinearLayout
android:orientation=”vertical”
android:baselineAlignedChildIndex=”1″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
>
<ImageView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/arrow_up_float”/>
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_marginRight=”5dip”
android:text=”@string/baseline_nested_1_label” />
<ImageView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/arrow_down_float”/>
</LinearLayout>
<!– We want the third index textview of this vertical linear layout to
be baseline aligned with the others.–>
<LinearLayout
android:orientation=”horizontal”
android:baselineAlignedChildIndex=”2″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”>
<ImageView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/arrow_up_float”/>
<ImageView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/arrow_up_float”/>
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_marginRight=”5dip”
android:text=”@string/baseline_nested_1_label” />
</LinearLayout>
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:textSize=”20sp”
android:text=”@string/baseline_nested_1_label” />
</LinearLayout>
![](http://www.imobilebbs.com/wordpress/wp-content/uploads/2011/07/20110708002.png)
相关文章推荐
- Android ApiDemos示例解析(139):Views->Layouts->Baseline->Nested Example 1
- Android ApiDemos示例解析(138):Views->Layouts->Baseline->6. Relative
- Android ApiDemos示例解析(133):Views->Layouts->Baseline->1.Top
- Android ApiDemos示例解析(140):Views->Layouts->Baseline->Nested Example 3
- Android ApiDemos示例解析(134):Views->Layouts->Baseline->2. Bottom
- Android ApiDemos示例解析(135):Views->Layouts->Baseline->3. Center
- Android ApiDemos示例解析(136):Views->Layouts->Baseline->4. Everywhere
- Android ApiDemos示例解析(137):Views->Layouts->Baseline->5. Multi-line
- Android ApiDemos示例解析(152):Views->Layouts->RelativeLayout->2.Simple Form
- Android ApiDemos示例解析(157):Views->Layouts->TableLayout->02. Empty Cells
- Android ApiDemos示例解析(153):Views->Layouts->ScrollView->1.Short
- Android ApiDemos示例解析(161):Views->Layouts->TableLayout->06. More Spanning and Stretchable
- Android ApiDemos示例解析(164):Views->Layouts->TableLayout->09. Toggle Shrink
- Android ApiDemos示例解析(154):Views->Layouts->ScrollView->2. Long
- Android ApiDemos示例解析(155):Views->Layouts->ScrollView->3. Internal Selection
- Android ApiDemos示例解析(165):Views->Layouts->TableLayout->10. Simple Form
- Android ApiDemos示例解析(156):Views->Layouts->TableLayout->01. Basic
- Android ApiDemos示例解析(162):Views->Layouts->TableLayout->07. Column Collapse
- Android ApiDemos示例解析(147):Views->Layouts->LinearLayout->7. Fill Parent
- Android ApiDemos示例解析(158):Views->Layouts->TableLayout->03.Long Content