拉伸和填充中间布局 Android

nis*_*doo 2 layout android autofill autosize stretch

我有一个主要的相对布局(高度,宽度=填充父),里面有 3 个布局:

1st: Frame Layout(width=fill_parent/height=wrap_content)
2nd: Linear Layout(width=fill_parent/height=wrap_content/layoutbelow 1st)
3rd: Relative Layout(height=wrap_content/width=fill parent/layout_alignParentBottom="true"/ layoutbelow 2nd)
Run Code Online (Sandbox Code Playgroud)

我希望第三个布局位于屏幕底部,第一个位于屏幕顶部,第二个布局填充两者之间的空间。我该怎么做呢?我点击了这个链接:Android LinearLayout fill-the-middle并尝试设置 layout_height="0px" 和 layout_weight="1" 但它没有用。任何人都可以帮我解决这个问题吗?

谢谢

pel*_*lus 5

IIRC 相对布局不支持 layout_weight。

所以你需要这样的东西:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0px"
        android:layout_wight="1" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

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