2012-10-15 38 views
3

我有以下困境。两个元素,一个在另一个之上。底部有高度为wrap_content。我希望顶层元素填充剩余空间,而不使两个元素重叠(如果我使用FrameLayout,则会发生这种情况)。所有元素的宽度为match_parent垂直布局,2个元素,使顶部填充剩余空间(底部有一个wrap_content)

这里的样机(某些属性截断清晰度):

<LinearLayout android:layout_height="match_parent"> 

    <CustomView android:layout_height="???????" /> 

    <TextView android:layout_height="wrap_content"> 

</LinearLayout> 

回答

9
<CustomView 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    .../> 
+0

“中的FrameLayout布局无效PARAM:layout_weight”。请注意,父'LinearLayout'没有定义'weightSum',这可能是原因。任何想法如何继续? –

+1

不,你不需要'weightSum'。这应该只是一个问题,如果直接父母是一个“FrameLayout”,而不是像上面显示的那样的“LinearLayout”。如果你在'FrameLayout'中需要它,将加权视图包装在'LinearLayout'中。 – Geobits

+0

你是对的。出于某种原因,我使用了FrameLayout。 –

相关问题