1、概述
布局管理器的用途:
a、可以更好的管理组件;
b、通过使用布局管理器,Android应用程序可以做到平台无关性
布局管理器都是ViewGroup的子类,所有可充当容器的父类都是ViewGroup,而ViewGroup也是View的子类
下面分别介绍常用的布局管理器
2、线性布局管理器
LinearLayout,最常用的布局之一。它提供控件水平或垂直排列的模型
常用属性及其对应方法:
gravity 可取属性说明:
当需要为gravity设多个值时,可用|分隔开
布局XML:
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:orientation="horizontal" 4 android:layout_width="fill_parent" 5 android:layout_height="fill_parent" 6 android:id="@+id/lla" 7 android:gravity="right" 8 > 9 10 <Button 11 android:text="添加" 12 android:id="@+id/Button01" 13 android:layout_width="wrap_content" 14 android:layout_height="wrap_content"> 15 </Button> 16 17 </LinearLayout>