3

I have the following dilemma. Two elements, one on top of each other. The bottom has wrap_content for height. I want the top element to fill the remaining space without the two elements overlapping (which happens if I use FrameLayout for example).

The width is match_parent for all elements.

Here's a mockup (some attributes truncated for clarity):

<LinearLayout android:layout_height="match_parent">

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

  <TextView android:layout_height="wrap_content">

</LinearLayout>
Dzhuneyt
  • 8,437
  • 14
  • 64
  • 118

1 Answers1

10
<CustomView 
    android:layout_height="0dp"
    android:layout_weight="1"
    .../>
Geobits
  • 22,218
  • 6
  • 59
  • 103
  • "Invalid layout param in a FrameLayout: layout_weight". Note that the parent `LinearLayout` doesn't have a `weightSum` defined, which may be the reason for this. Any idea how to proceed? – Dzhuneyt Oct 15 '12 at 13:29
  • 1
    No, you don't need `weightSum` to be there. This should only be a problem if the immediate parent is a `FrameLayout`, not a `LinearLayout` as you've shown above. If you need it in a `FrameLayout`, wrap the weighted view in a `LinearLayout`. – Geobits Oct 15 '12 at 13:31