0

我在理解如何在xml文件中将各个层叠在一起。 我搜索了一个解决方案,但找不到满足我需求的解决方案。将LinearLayout与LinearLayout在RelativeLayout中对齐

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

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

enter image description here

这里是我测试的是什么(会延长第一布局和隐藏第二)。

<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。

回答

1

我设法找到解决我的问题。 我用一个FrameLayout更改了第一个LinearLayout,并且所有的东西都像它应该那样工作。请记住,第二个LinearLayout必须停留在FrameLayout之下。干杯!