要实现如图的布局:
这是在eclipse可视化窗口中的截图,但实际运行在Android设备上可能出现的问题有:
(1):当编辑图1中的最后一个EditText时,输入法的编辑界面会把底部的Button顶上去,遮挡住了最后一个EditText;
(2):图2中的控件太多,以至于无法一屏全部显示,导致底部的Button被挤下去,又无法滚动控件,导致无法操作Button;
解决方案:
以下为布局文件代码:
图 1:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <ScrollView android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_above="@+id/linearLayout1" android:fillViewport="true" > <TableLayout android:id="@+id/table" android:layout_width="fill_parent" android:layout_height="wrap_content" android:stretchColumns="1" > <TableRow> <TextView android:layout_width="60dp" android:layout_height="wrap_content" android:text="@string/product_name" /> <EditText android:layout_height="wrap_content" android:hint="@string/product_name" > </EditText> </TableRow> <TableRow> <TextView android:layout_width="60dp" android:layout_height="wrap_content" android:text="@string/product_id" /> <EditText android:layout_height="wrap_content" android:hint="@string/product_id" > </EditText> </TableRow> <TableRow> <TextView android:layout_width="60dp" android:layout_height="wrap_content" android:text="@string/raise_company" /> <EditText android:layout_height="wrap_content" android:hint="@string/raise_company" > </EditText> </TableRow> <TableRow> <TextView android:layout_width="80dp" android:layout_height="wrap_content" android:text="@string/about_info" /> <EditText android:layout_height="wrap_content" android:layout_weight="2" android:hint="@string/about_quality_website" > </EditText> </TableRow> </TableLayout> </ScrollView> <LinearLayout android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:paddingBottom="0dp" > <Button android:layout_width="70dp" android:layout_height="wrap_content" android:layout_weight="2" android:text="@string/edit" /> <Button android:layout_width="70dp" android:layout_height="wrap_content" android:layout_weight="2" android:text="@string/refer" > </Button> </LinearLayout> </RelativeLayout>