Android 水平回收视图低于垂直回收视图

Android 水平回收视图低于垂直回收视图,android,xml,Android,Xml,我正在尝试实现一些聊天问题(垂直循环视图),并在垂直循环视图下提供答案(水平循环视图) 然而,我已经实现了我心中的目标: 我现在所拥有的: 垂直rv运行良好,水平rv位于视图底部; 我想要的是: 我想在垂直rv展开时,在其正下方找到答案,因此,如果垂直rv有一个itemview,它应该在其正下方,并在其展开时,直到水平rv到达视图底部 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

我正在尝试实现一些聊天问题(垂直循环视图),并在垂直循环视图下提供答案(水平循环视图) 然而,我已经实现了我心中的目标: 我现在所拥有的: 垂直rv运行良好,水平rv位于视图底部; 我想要的是: 我想在垂直rv展开时,在其正下方找到答案,因此,如果垂直rv有一个itemview,它应该在其正下方,并在其展开时,直到水平rv到达视图底部

<LinearLayout
    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"
    android:orientation="vertical">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/verticalRecyclerView"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:scrollbars="vertical"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/horizontalRecyclerView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:orientation="horizontal"/>

</LinearLayout>

将xml编辑为

<LinearLayout
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"
android:orientation="vertical">

<android.support.v7.widget.RecyclerView
    android:id="@+id/verticalRecyclerView"
    android:layout_width="match_parent"     
    android:layout_height="0dp"
    android:layout_weight="1"
    android:scrollbars="vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

<android.support.v7.widget.RecyclerView
    android:id="@+id/horizontalRecyclerView"
    android:layout_width="wrap_content"      
    android:layout_height="0dp"
    android:layout_weight="0.5"
    android:layout_gravity="center_horizontal"
    android:orientation="horizontal"/>

</LinearLayout>
垂直循环使用

LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);

RecyclerView myList = (RecyclerView)findViewById(R.id.my_recycler_view);
myList.setLayoutManager(layoutManager);

只需为LinearLayout android添加weightsum属性:weightsum=1.5,并确保适配器中没有空格(如果您也给出了空格),这将影响性能 如果你同意我的回答,请投票
<LinearLayout
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"
android:weightsum = "1.5"
android:orientation="vertical">

<android.support.v7.widget.RecyclerView
    android:id="@+id/verticalRecyclerView"
    android:layout_width="match_parent"     
    android:layout_height="0dp"
    android:layout_weight="1"
    android:scrollbars="vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

<android.support.v7.widget.RecyclerView
    android:id="@+id/horizontalRecyclerView"
    android:layout_width="match_parent"      
    android:layout_height="0dp"
    android:layout_weight="0.5"
    android:layout_gravity="center_horizontal"
    android:orientation="horizontal"/>

</LinearLayout>

不起作用,尽管垂直回收视图只有一个项目,但它下面有很多空白,一旦填满,有很多空间低于水平回收视图你必须设置重量为两个回收查看如果你设置了包装内容,然后上回收视图隐藏低回收查看时,它包含更多的信息,但这样,我结束了水平RV在中间的布局,直到垂直视图是填补,然后填补它,在horionztal recyclerview下面有一个空的空间,我想要实现的是在上面一个下面有第二个recyclerview,在上部填充之前,第二个回收视图将粘在底部,然后移除重量,并将两辆rv的wrp_含量设置为高度。请在回答中包含如何执行的实际代码,以便询问者知道如何执行。
<LinearLayout
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"
android:weightsum = "1.5"
android:orientation="vertical">

<android.support.v7.widget.RecyclerView
    android:id="@+id/verticalRecyclerView"
    android:layout_width="match_parent"     
    android:layout_height="0dp"
    android:layout_weight="1"
    android:scrollbars="vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

<android.support.v7.widget.RecyclerView
    android:id="@+id/horizontalRecyclerView"
    android:layout_width="match_parent"      
    android:layout_height="0dp"
    android:layout_weight="0.5"
    android:layout_gravity="center_horizontal"
    android:orientation="horizontal"/>

</LinearLayout>