2011-09-05 126 views
27
之外的其餘空間

我有一個相對佈局。爲簡單起見,有一個ImageViewEditTextButtonAndroid佈局 - 填充除

  • ImageView與固定高度
  • 下面即與EditText其中android:layout_width="fill_parent"
  • 在其下面的橫幅是Button具有固定寬度和高度

問題是我想要editText填充屏幕的剩餘高度。在頂部放置圖像,在底部放置一個按鈕,在中間放置一個按鈕,然後編輯佔據剩餘空間的文本。

我需要使用哪些屬性才能獲得與此相似的內容?

+3

小點:「fill_parent」已棄用。改用「match_parent」。請參閱http://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html#FILL_PARENT –

回答

64

爲此目的,有LinearLayoutlayout_weight屬性。使用LinearLayout來保存這3個元素。對於ButtonImageView,將layout_height設爲wrap_content。對於EditText集合layout_height="0dp"layout_weight="1"

3

您是否考慮過使用Relative Layout

你可以使用


android:layout_below
android:layout_alignParentTop
android:layout_alignParentBottom
android:layout_marginTop
android:layout_marginBottom

試一下,並張貼一些示例代碼,如果你會被卡住。