我需要有一個比屏幕大的用戶窗體。該佈局由一個固定的「標題區域」,表單(可能在scrollview中)和底部的按鈕組成。我創建了三個佈局,中間佈局是一個帶垂直方向LinearLayout的ScrollView。不幸的是,表單將按鈕從屏幕上推出?!如何佈置在Android SDK中滾動的表單?
有沒有一個簡單的例子來做到這一點?
我想我可以使用ListView,但我會認爲我的ScrollView更容易管理。這是我的佈局......
<?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"
>
<!-- Title Area on top -->
<LinearLayout
android:id="@+id/layout_form"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="0dip"
android:layout_marginBottom="0dip"
android:paddingTop="20dip"
android:paddingBottom="20dip"
android:paddingLeft="5dip"
android:paddingRight="10dip"
android:src="@drawable/logo"
android:layout_gravity="center"
android:layout_weight="1"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="2"
android:layout_marginTop="0dip"
android:layout_marginBottom="0dip"
android:layout_marginLeft="4dip"
android:layout_marginRight="4dip"
android:text="@string/title_create"
/>
</LinearLayout>
<!-- Form entry on top -->
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:clipChildren="true"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="8dip"
android:layout_marginRight="8dip"
android:text="@string/label_field_one"
/>
<EditText
android:id="@+id/edit_field_one"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:hint="@string/hint_field_one"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="8dip"
android:layout_marginRight="8dip"
android:text="@string/label_field_two"
/>
<EditText
android:id="@+id/edit_field_two"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:hint="@string/hint_field_two"
/>
<!-- Repeat label-text and edit-text until done ... -->
</LinearLayout>
</ScrollView>
<!-- "spring" between form and wizard buttons. -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="2"
>
<Button
android:id="@+id/btn_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:text="@string/button_submit"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
是的,我正在尋找標題(指導)/頁腳(可操作)與中間滾動的窗體。我現在將編碼,並讓你知道這是否適用於我的佈局。 – mobibob 2010-12-01 22:59:01