Android UI LinearLayout权限级别与TableLayout混合使用,特别要注意
android:layout_weight="5"
android:layout_weight="1"
很重要,如果设置不正确,显示将不是我们想要的结果。
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="5" > <TableLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchColumns="2" > <TableRow> <ImageButton android:src="@drawable/home" android:padding="3dip" /> <ImageButton android:src="@drawable/home" android:padding="3dip" /> <TextView android:text="标题——音乐播放器" android:gravity="center" /> <ImageButton android:src="@drawable/home" android:padding="3dip" /> <ImageButton android:src="@drawable/home" android:padding="3dip" /> </TableRow> </TableLayout> </LinearLayout> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" > <TextView android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_horizontal" android:text="浏览器放的地方" android:layout_weight="1" /> </LinearLayout> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:layout_weight="5" > <ImageButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/home42" /> <ImageButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/home42" /> <ImageButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/home42" /> <ImageButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/home42" /> </LinearLayout></LinearLayout>
?在上面种一共有四个LinearLayout,主LinearLayout默认是0,显示级别最大。其次是中间的LinearLayout我设置为2,在这个段代码中,它的显示级别为第二。剩下的就是最上面和最下面的LinearLayout了,他们的显示级别在本代码中排第三,我设置为5,其实你也可以设置为3,4,6,等,但一定要比中间的LinearLayout的显示级别大。要不然会被中间的LinearLayout覆盖掉。