2011-09-05 125 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

试一下,并张贴一些示例代码,如果你会被卡住。