展会信息港展会大全

Android ApiDemos示例解析(134):Views->Layouts->Baseline->2. Bottom
来源:互联网   发布日期:2015-10-13 17:07:19   浏览:2271次  

导读:LinearLayout的android:layout_gravity 定义了子View的对齐方式可以有下面几种:top: 和父容器的顶端对齐,不对子View进行缩放。bottom: 和父...

LinearLayout的android:layout_gravity 定义了子View的对齐方式可以有下面几种:

top: 和父容器的顶端对齐,不对子View进行缩放。

bottom: 和父容器的底端对齐,不对子View进行缩放。

left: 和父容器的左端对齐,不对子View进行缩放。

right: 和父容器的右端对齐,不对子View进行缩放。

center_vertical: 将子View居中(垂直居中),不对子View进行缩放。

fill_vertical: 将子View的垂直方向拉伸充满容器。

center_horizontal: 将子View居中(水平居中),不对子View进行缩放。

fill_horizontal: 将子View的水平方向拉伸充满容器。

center: 将子View居中(水平和垂直都居中),不对子View进行缩放。

fill: 将子View水平和垂直方向都拉伸充满整个容器。

clip_vertical:垂直裁剪子View

clip_horizontal: 水平裁剪子View。

多种选项可以使用“|” 隔开。

本例对三个子View都使用bottom 对齐方式,应为Linerlayout缺省采用baseline 对齐,因此三个View文字基准线是对齐的。

<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”

android:orientation=”horizontal”

android:layout_width=”match_parent”

android:layout_height=”match_parent”>

<TextViewwww.2cto.com

android:layout_width=”wrap_content”

android:layout_height=”wrap_content”

android:layout_marginRight=”3dip”

android:layout_gravity=”bottom”

android:text=”@string/baseline_2_label” />

<Button

android:layout_width=”wrap_content”

android:layout_height=”wrap_content”

android:layout_marginRight=”3dip”

android:layout_gravity=”bottom”

android:text=”@string/baseline_2_button” />

<TextView

android:layout_width=”wrap_content”

android:layout_height=”wrap_content”

android:layout_gravity=”bottom”

android:textSize=”20sp”

android:text=”@string/baseline_2_bigger” />

</LinearLayout>

赞助本站

人工智能实验室

相关热词: android开发 教程

AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港