在 RelativeLayout 中将 LinearLayout 对齐到 LinearLayout

Align LinearLayout over LinearLayout inside a RelativeLayout

我很难理解如何在 xml 文件中逐层对齐图层。 我搜索了一种解决方案,但找不到满足我需要的解决方案。

我在一个 RelativeLayout 中有两个 LinearLayout。第一个 LinearLayout 包含一个 RecycleView/ScrollView,第二个 LinearLayout 包含一些按钮。

我想将第二个 LinearLayout 设置在第一个 LinearLayout 之上,但在 RelativeLayout 的底部。见下图。

这是我测试过的(它会扩展第一个布局并隐藏第二个布局)。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
    android:id="@+id/first"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</LinearLayout>

<LinearLayout
    android:id="@+id/second"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_below="@+id/first"
    android:layout_alignParentBottom="true"
    app:layout_gravity="bottom">
</LinearLayout>

</RelativeLayout>

你知道如何实现吗?

PS。我不想使用 BottomNavigationView 而不是第二个 LinearLayout。

我设法找到了解决问题的办法。 我用 FrameLayout 更改了第一个 LinearLayout,一切正常。请记住,第二个 LinearLayout 必须位于 FrameLayout 之下。干杯!