垂直布局,2个元素,使顶部填充剩余空间(底部有一个wrap_content)

Dzh*_*eyt 3 height android android-layout xml-layout

我有以下两难困境.两个元素,一个在彼此之上.底部有wrap_content高度.我希望顶部元素填充剩余的空间而不会重叠两个元素(例如,如果我使用的话会发生这种情况FrameLayout).

宽度适用match_parent于所有元素.

这是一个模型(为清晰起见,一些属性被截断):

<LinearLayout android:layout_height="match_parent">

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

  <TextView android:layout_height="wrap_content">

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

Geo*_*its 9

<CustomView 
    android:layout_height="0dp"
    android:layout_weight="1"
    .../>
Run Code Online (Sandbox Code Playgroud)