前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Android - 常见的控件布局,左中右,左右等

Android - 常见的控件布局,左中右,左右等

作者头像
宋凯伦
发布2018-01-04 14:56:56
2.3K0
发布2018-01-04 14:56:56
举报

这里汇总的是自己在工作过程中,使用过的常见空间布局,记录在这里。详情如下:

1. 三个控件,分别处于左,中,右

要点:使用RelativeLayout

代码语言:javascript
复制
 1     <RelativeLayout
 2                 android:layout_width="match_parent"
 3                 android:layout_height="wrap_content"
 4                 android:orientation="horizontal">
 5             <TextView
 6                     android:layout_width="wrap_content"
 7                     android:layout_height="wrap_content"
 8                     android:gravity="center"
 9                     android:layout_alignParentLeft="true"/>
10             <TextView
11                     android:layout_width="wrap_content"
12                     android:layout_height="wrap_content"
13                     android:gravity="center"
14                     android:layout_centerHorizontal="true"/>
15             <TextView
16                     android:layout_width="wrap_content"
17                     android:layout_height="wrap_content"
18                     android:gravity="center"
19                     android:layout_alignParentRight="true"/>
20     </RelativeLayout>

2. 两个控件,分别处于左右

要点:使用layout_weight="1"的TextView撑开中间,将两个控件挤到两边

代码语言:javascript
复制
 1         <LinearLayout
 2             android:layout_width="match_parent"
 3             android:layout_height="wrap_content"
 4             android:orientation="horizontal">
 5             <TextView
 6                     android:layout_width="wrap_content"
 7                     android:layout_height="wrap_content"
 8                     android:gravity="center"
 9                     android:layout_gravity="center"/>
10             <TextView
11                     android:layout_width="wrap_content"
12                     android:layout_height="wrap_content"
13                     android:layout_weight="1" />
14             <TextView
15                     android:layout_width="wrap_content"
16                     android:layout_height="wrap_content"
17                     android:gravity="center"
18                     android:layout_gravity="center"/>
19         </LinearLayout>

持续更新......

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-07-05 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档