Android LinearLayout线性布局
2017-09-13 14:06
405 查看
LinearLayout是线性布局控件:要么横向排布,要么竖向排布
决定性属性:必须有的!
android:orientation:vertical (垂直方向) 、horizontal(水平方向)
常用属性:
android:gravity------------设置的是控件自身上面的内容位置
android:layout_gravity-----设置控件本身相对于父控件的显示位置
android:layout_weight----- 给控件分配剩余空间
决定性属性:必须有的!
android:orientation:vertical (垂直方向) 、horizontal(水平方向)
常用属性:
android:gravity------------设置的是控件自身上面的内容位置
android:layout_gravity-----设置控件本身相对于父控件的显示位置
android:layout_weight----- 给控件分配剩余空间
竖向排布实例: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮1" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮2" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮3" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮4" /> </LinearLayout>
横向排布实例: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮1" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮2" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮3" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮4" /> </LinearLayout>
嵌套线性布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <LinearLayout > .. </LinearLayout> <LinearLayout> .. </LinearLayout> </LinearLayout>
相关文章推荐
- android五大布局之LinearLayout(线性布局)
- Android线性布局LinearLayout,及盒模型,weight权值,ScrollView和HorizontalScrollView【内容溢出(内容太多,高度/宽度大于能显示的最大高度/宽度)】
- Android BGABadgeView:BGABadgeLinearLayout以整体线性布局作为BadgeView(3)
- android 五大布局之LinearLayout(线性布局)
- android开发布局一_线性布局(LinearLayout)
- Android LinearLayout(线性布局)
- Android 线性布局(LinearLayout)相关官方文档 - 指南部分
- Android BGABadgeView:BGABadgeLinearLayout以整体线性布局作为BadgeView(3)
- android之线性布局LinearLayout以及weight权重使用
- Android 线性布局(LinearLayout)性能相关
- Android布局(线性布局 Linear Layout )(相对布局 Relative Layout)
- 第12章、布局Layouts之LinearLayout线性布局(从零开始学Android)
- (一)Android布局之线性布局(LinearLayout)
- Android布局之LinearLayout线性布局
- Android布局之LinearLayout(线性布局)
- 第12章、布局Layouts之LinearLayout线性布局(从零开始学Android)
- Android 使用线性布局LinearLayout和Button实现一个点红块游戏
- Android中的线性布局(LinearLayout)
- Android Layout布局使用总结Android中常用的5大布局方式有以下几种: 线性布局(LinearLayout):按照垂直或者水平方向布局的组件。 帧布局(FrameLayout):组件从