Android ApiDemos示例解析(140):Views->Layouts->Baseline->Nested Example 3
本例使用了两层LinearLayout嵌套:
<!– We’ll point to the linear layout to baseline align by, which
in turn will point to a text view inside of it –>
<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”/>
<LinearLayout
android:orientation=”vertical”
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>
</LinearLayout>
第一层android:baselineAlignedChildIndex=”1″ 指定第二层LinearLayout ,第二个android:baselineAlignedChildIndex=”2″ 为第二级LinearLayout中的TextView,注意同样要去掉XML中的android:layout_gravity=”center_vertical”
更多相关文章
- Android静态,动态广播示例
- android LinearLayout嵌套 button时onClickListener不响应的问题
- scrollView嵌套recyclerView 显示不全
- RadioGroup+RadioButton嵌套实现多行单选效果
- Android Jni代码示例讲解
- Android 统计图表引擎 AChartEngine(三) - 示例源码折线图、饼图
- GridView示例2(自动增长)
- Android GridView 使用示例
- Android Studio 官方示例源码地址