API地址:file:///D:/Android/sdk/docs/reference/android/widget/LinearLayout.html
layout文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">-------------------垂直
<TextView android:text="文本1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textSize="10pt"
android:background="#BBFFFF"-----------------十六进制RGB
android:paddingTop="5dip"--------------------文字离TextView上边框距离 dip相对pt对屏幕分辨率兼容更好
android:paddingBottom="5dip"
android:paddingLeft="15dip"
android:paddingRight="5dip"
android:singleLine="true"/>-------------------文字单行显示,超出部分...显示
<TextView android:text="文本2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textSize="10pt"
android:background="#AEEEEE"
android:paddingTop="5dip"
android:paddingBottom="5dip"
android:paddingLeft="15dip"
android:paddingRight="5dip"
android:singleLine="true"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">----------------------嵌入LinearLayout
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"-------------------------在布局文件占权重
android:text="Button1"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button2"/>
</LinearLayout>
</LinearLayout>
效果:
参见:LinearLayout类