0
在我的表單上我有一個標籤,一個多行文本框和一些按鈕。我希望將按鈕對齊到活動底部,多行文本框填充剩餘空間。填充剩餘空間,但也有按鈕對齊底部
我可以讓按鈕捕捉到底部的唯一方法是在容器上使用android:layout_alignParentBottom,這意味着主佈局必須是Relative。
但是,我可以通過多行文本框填充空間的唯一方法是容器是線性佈局,並使用0dp/weight = 1。
底部的包含只是一個帶按鈕的水平線性佈局。
有沒有辦法做到這一點?如下所示,我嘗試過使用Table Rows等。下面是它現在的樣子。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/fragmentBackdropPlain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/buttonText"
android:text="@string/subtopic_content_name"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TableRow android:id="@+id/tableRow1" android:layout_width="match_parent" android:layout_height="wrap_content"></TableRow>
<EditText
android:id="@+id/editSubTopicContent"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:hint="@string/subtopic_content_hint"
android:inputType="textMultiLine" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
<include layout="@layout/include_edit_buttons" />
</LinearLayout>
</RelativeLayout>
輝煌,謝謝。如何聲明上面的按鈕使其工作?我只是假定按照我想要的順序放置它們,並告訴項目在上/下/相對於另一個不會影響XML中的順序。 –
@尼爾我在答案中添加了一個解釋! – MalaKa
啊,歡呼聲,我從來沒有想到這一點。現在我知道,當我得到佈局的其他問題時,它應該更有意義:) –