小编Soh*_*een的帖子

在布局中使用多个RecyclerViews进行控制

我创建了一个有两个RecyclerViews的布局.一个水平滚动,而另一个垂直滚动.我可以在每个RecyclerView内正确滚动,但页面整体不会滚动,即顶部的RecyclerView始终保持在顶部,而底部保持在底部,就像两个都固定在位.

以下是我的xml布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

        <EditText
            android:id="@+id/search"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:hint="Search Dramas"
            android:textSize="16sp"
            android:paddingLeft="10dp"
            android:gravity="center"
            android:textColor="@color/dark_grey"
            android:textColorHint="@color/dark_grey"
            android:background="@drawable/border_bottom"/>


        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/border_bottom_background_black"
            android:textColor="@color/white"
            android:padding="10dp"
            android:text="Most Watched"/>

        <!-- A RecyclerView to display horizontal list -->
        <android.support.v7.widget.RecyclerView
            android:id="@+id/featured"
            android:scrollbars="none"
            android:layout_width="fill_parent"
            android:layout_height="240dp"
            android:paddingLeft="0dp"
            android:paddingRight="15dp"
            android:paddingTop="15dp"
            android:paddingBottom="25dp"
            android:background="@color/black"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/border_bottom_backgroundless"
            android:textColor="@color/dark_grey"
            android:padding="10dp"
            android:text="All Dramas"/>

        <!-- A RecyclerView to display vertical list -->
        <android.support.v7.widget.RecyclerView
            android:id="@+id/pick_item"
            android:scrollbars="vertical"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"/>


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

活动的样子

android scrollview android-linearlayout android-recyclerview

6
推荐指数
2
解决办法
1万
查看次数