9,//LinearLayout
<!--
LinearLayout:线性布局
android:id -为控件指定相应的ID
android:text -指定控件当中显示的文字,需要注意的是,尽量使用string.xml
android:gravity ——指定控件的基本位置,比如说居中,居右等位置
android:textSize ——指定控件当中字体的大小
android:background ——指定控件所使用的背景色,RGB命名法
android:width ——指定空间的宽度
android:height ——指定控件的高度
android:padding* ——指定控件的内边距,控件当中内容距离边距的位置
android:sigleLine ——如果设置为真的话,则将控件的内容在同一行当中进行显示
android:layout_weight ——权重
-->
//设置了权重为何无效果???? 需要将每个textView的宽和高都设置为填充父类,这样设置权重时就有效了
//同时使用TableLayout和LinearLayout时,需要设置相同的权重,才能同时显示两个控件,否则会被覆盖
1 <TextView 2 android:id="@+id/firstText" 3 android:text="@string/firsttext" 4 android:gravity="center_vertical" 5 android:textSize="35pt" 6 android:background="#aa0000" 7 android:layout_width="fill_parent" 8 android:layout_height="wrap_content" 9 android:paddingLeft="10dip" 10 android:paddingTop="20dip" 11 android:paddingRight="30dip" 12 android:paddingBottom="40dip" 13 android:layout_weight="1" 14 android:singleLine="true" />
10,//TableLayout
1 <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 android:layout_width="fill_parent" 3 android:layout_height="fill_parent" 4 android:stretchColumns="2" > 5 <TableRow > 6 <TextView 7 android:text="@string/row1_column0" 8 android:padding="3dip" 9 android:background="#aa0000"/> 10 <TextView 11 android:text="@string/row1_column1" 12 android:padding="3dip" 13 android:background="#00aa00"/> 14 <TextView 15 android:text="@string/row1_column2" 16 android:padding="3dip" 17 android:background="#0000aa" /> 18 </TableRow> 19 <TableRow > 20 <TextView 21 android:text="@string/row2_column0" 22 android:padding="3dip" 23 android:background="#aa0000" /> 24 <TextView 25 android:text="@string/row2_column1" 26 android:padding="3dip" 27 android:background="#00aa00" /> 28 <TextView 29 android:text="@string/row2_column2" 30 android:padding="3dip" 31 android:background="#0000aa"/> 32 </TableRow> 33 </TableLayout>
11,//RelativeLayout
1 android:layout_above 将该控件至于给定ID控件之上 2 android:layout_below 将该控件至于给定ID控件之下 3 android:layout_toLeftOf 将该控件至于给定ID控件左侧 4 android:layout_toRightOf 将该控件至于给定ID控件的右侧 5 6 android:layout_alignBaseline 将该控件的baseline和指定ID控件的baseline对齐 7 android:layout_alignBottom 将该控件的底部边缘与给定ID控件的底部边缘对齐 8 android:layout_alignLeft 将该控件的左边缘与指定ID控件的左边缘对齐 9 android:layout_alignRight 将该控件的有边缘与指定ID控件的右边缘对齐 10 android:layout_alignTop 将给定控件的顶部边缘与给定ID控件的顶部对齐 11 12 android:layout_alignParentBottom 如果为true,将该控件的底部和父控件的底部对齐 13 android:layout_alignParentLeft 如果为true,将该控件的左边与父控件的左边对齐 14 android:layout_alignParentRight 如果为true,将该控件的右边与父控件的右边对齐 15 android:layout_alignParentTop 如果为true,将控件的顶部与父控件的顶部对齐 16 17 android:layout_centerHorizontal 如果值为true,该控件被至于水平方向中央 18 android:layout_centerInParent 如果值为true,该控件被至于父控件水平方向和垂直方向中央 19 android:layout_centerVertical 如果值为true,该控件将被至于垂直方向的中央
//layout_marginLeft 整个按钮距离左边内容的距离
//layout_paddingLeft 按钮上内容距离左边界
1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 android:layout_width="fill_parent" 3 android:layout_height="fill_parent" 4 android:padding="10px" > 5 6 <TextView 7 android:id="@+id/label" 8 android:layout_width="fill_parent" 9 android:layout_height="wrap_content" 10 android:text="@string/typehere" /> 11 <EditText 12 android:id="@+id/entry" 13 android:layout_width="fill_parent" 14 android:layout_height="wrap_content" 15 android:background="@android:drawable/editbox_background" 16 android:layout_below="@id/label"/> 17 <Button 18 android:id="@+id/ok" 19 android:layout_width="wrap_content" 20 android:layout_height="wrap_content" 21 android:layout_below="@id/entry" 22 android:layout_alignParentRight="true" 23 android:layout_marginLeft="10dp" 24 android:text="@string/okButton"/> 25 <Button 26 android:layout_width="wrap_content" 27 android:layout_height="wrap_content" 28 android:layout_toLeftOf="@id/ok" 29 android:layout_alignTop="@id/ok" 30 android:text="@string/cancelButton" /> 31 </RelativeLayout>
12,//ScrollView,页面自动滚动
13,//FrameLayout
<1>,最简单,在屏幕上保留空间,之后填充单独对象
<2>,所有元素都在屏幕左上角
<3>,不能为子元素指定位置
14,//AbsoluteLayout
建议不使用,不同的设备显示不同,需要指出确切的X,Y坐标位置