我有 3 个布局,main.xml、layout1.xml、layout2.xml。
layout1.xml 有大约 10 个文本字段,layout2.xml 有 4 个按钮
在 main.xml 中,我将其他 2 个布局称为
<include layout="@layout/data_layout"/>
<include layout="@layout/button_layout"
android:layout_alignBottom="@layout/data_layout" />
现在我的问题是 layout1.xml 和 layout2.xml 都重叠在另一个之上。但我需要 layout2.xml 必须从 layout1.xml 的底部开始
关于这个有什么想法吗?
Main_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/nieTxtState"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:padding="@dimen/padding_medium"
android:text="@string/state"
android:textSize="14dp" />
<TextView
android:id="@+id/nieTxtTNState"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/nieTxtState"
android:padding="@dimen/padding_medium"
android:text="@string/tnState"
android:textSize="14dp" />
<include
layout="@layout/data_layout"/>
<include
layout="@layout/button_layout"
android:layout_alignBottom="@layout/data_layout" />
</RelativeLayout>
数据布局.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/light_blue"
android:orientation="vertical"
android:scrollbars="vertical" >
<TextView
android:id="@+id/nieTxtState"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:padding="@dimen/padding_medium"
android:text="@string/state"
android:textSize="14dp" />
<TextView
android:id="@+id/nieTxtTNState"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/nieTxtState"
android:padding="@dimen/padding_medium"
android:text="@string/tnState"
android:textSize="14dp" />
<TextView
android:id="@+id/txtViewDistrict"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/nieTxtTNState"
android:layout_marginLeft="5dp"
android:text="@string/district"
android:textColor="@color/black" />
<Spinner
android:id="@+id/spnDistrict"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txtViewDistrict"
android:layout_marginLeft="2dp" />
<TextView
android:id="@+id/txtViewHSS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/spnDistrict"
android:layout_marginLeft="5dp"
android:text="@string/hssSite"
android:textColor="@color/black" />
<Spinner
android:id="@+id/spnHSS"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txtViewHSS"
android:layout_marginLeft="2dp" />
<TextView
android:id="@+id/txtViewAge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/spnHSS"
android:layout_marginLeft="5dp"
android:text="@string/age"
android:textColor="@color/black" />
<EditText
android:id="@+id/edtTxtAge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txtViewAge"
android:layout_marginLeft="2dp"
android:hint="@string/hintAge"
android:inputType="number"
android:maxLength="2"
android:textSize="14dp" />
<TextView
android:id="@+id/txtViewLiteracy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/edtTxtAge"
android:layout_marginLeft="5dp"
android:text="@string/literacyStatus"
android:textColor="@color/black" />
<Spinner
android:id="@+id/spnLiteracy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txtViewLiteracy"
android:layout_marginLeft="2dp" />
<TextView
android:id="@+id/txtViewPregnancy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/spnLiteracy"
android:layout_marginLeft="5dp"
android:text="@string/currentPregnancy"
android:textColor="@color/black" />
<Spinner
android:id="@+id/spnPregnancy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txtViewPregnancy"
android:layout_marginLeft="2dp" />
<TextView
android:id="@+id/txtViewReferralSource"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/spnPregnancy"
android:layout_marginLeft="5dp"
android:text="@string/referralSource"
android:textColor="@color/black" />
<Spinner
android:id="@+id/spnReferralSource"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txtViewReferralSource"
android:layout_marginLeft="2dp" />
<TextView
android:id="@+id/txtViewResidence"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/spnReferralSource"
android:layout_marginLeft="5dp"
android:text="@string/residecnePlace"
android:textColor="@color/black" />
<Spinner
android:id="@+id/spnResidence"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txtViewResidence"
android:layout_marginLeft="2dp" />
<TextView
android:id="@+id/txtViewDurationOfStay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/spnResidence"
android:layout_marginLeft="5dp"
android:text="@string/DurationOfStay"
android:textColor="@color/black" />
<EditText
android:id="@+id/edtTxtDurationOfYear"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_below="@id/txtViewDurationOfStay"
android:layout_marginLeft="2dp"
android:layout_marginRight="20dp"
android:hint="@string/hintYear"
android:inputType="number"
android:maxLength="4"
android:textSize="14dp" />
<EditText
android:id="@+id/edtTxtDurationOfMonth"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_below="@id/txtViewDurationOfStay"
android:layout_toRightOf="@id/edtTxtDurationOfYear"
android:hint="@string/hintMonth"
android:inputType="number"
android:maxLength="2"
android:textSize="14dp" />
<TextView
android:id="@+id/txtViewRespOccupation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/edtTxtDurationOfYear"
android:layout_marginLeft="5dp"
android:text="@string/respondentOccupation"
android:textColor="@color/black" />
<Spinner
android:id="@+id/spnRespOccupation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txtViewRespOccupation"
android:layout_marginLeft="2dp" />
<TextView
android:id="@+id/txtViewSpouseOccupation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/spnRespOccupation"
android:layout_marginLeft="5dp"
android:text="@string/spouseOccupation"
android:textColor="@color/black" />
<Spinner
android:id="@+id/spnSpouseOccupation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txtViewSpouseOccupation"
android:layout_marginLeft="2dp" />
<TextView
android:id="@+id/txtViewSpouseResidesAwayFromWife"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/spnSpouseOccupation"
android:layout_marginLeft="5dp"
android:text="@string/spouseResidesAwayFromWife"
android:textColor="@color/black" />
<Spinner
android:id="@+id/spnSpouseResidesAwayFromWife"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txtViewSpouseResidesAwayFromWife"
android:layout_marginLeft="2dp" />
</RelativeLayout>
button_layout.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="bottom">
<Button
android:id="@+id/ancSaveBtn"
android:layout_width="80dp"
android:layout_height="35dp"
android:layout_alignParentLeft="true"
android:layout_marginTop="15dp"
android:text="@string/upload"
android:textSize="14dp" />
<Button
android:id="@+id/ancAddNewBtn"
android:layout_width="80dp"
android:layout_height="35dp"
android:layout_marginTop="15dp"
android:layout_toRightOf="@id/ancSaveBtn"
android:text="@string/addNew"
android:textSize="14dp" />
<Button
android:id="@+id/ancClearBtn"
android:layout_width="80dp"
android:layout_height="35dp"
android:layout_marginTop="15dp"
android:layout_toRightOf="@id/ancAddNewBtn"
android:text="@string/clear"
android:textSize="14dp" />
<Button
android:id="@+id/ancExitBtn"
android:layout_width="80dp"
android:layout_height="35dp"
android:layout_marginTop="15dp"
android:layout_toRightOf="@id/ancClearBtn"
android:text="@string/exit"
android:textSize="14dp" />
</RelativeLayout>