ListerCi 2017-09-01 09:40 采纳率: 60%
浏览 7281
已采纳

Android多个RecyclerView嵌套在NestedScrollView的滑动阻塞问题。

最近在做一个项目,做完首页,将多个RecyclerView嵌套在NestedScrollView中,在Android7.0以下都是流畅运行,但是在新买的Android7.1的手机上,滑动时有时会出现一点阻塞,求问这是为什么?界面和代码如下:
首页效果图:
首页
布局:

 <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

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

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_below="@+id/main_linear_search"
                android:layout_marginTop="15dp">

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/home_rv_convenient"
                    android:layout_width="wrap_content"
                    android:layout_height="100dp">
                </android.support.v7.widget.RecyclerView>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="10dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginBottom="10dp"
                    android:background="@color/background_gray"/>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="20dp"
                    android:orientation="horizontal"
                    android:layout_gravity="center_horizontal"
                    android:gravity="center_vertical">
                    <View
                        android:layout_width="20dp"
                        android:layout_height="2dp"
                        android:background="@color/background_gray"/>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/black"
                        android:layout_marginLeft="5dp"
                        android:layout_marginRight="5dp"
                        android:textSize="12sp"
                        android:text="经典案例"/>
                    <View
                        android:layout_width="20dp"
                        android:layout_height="2dp"
                        android:background="@color/background_gray"/>
                </LinearLayout>

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

                <View
                    android:layout_width="match_parent"
                    android:layout_height="10dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginBottom="10dp"
                    android:background="@color/background_gray"/>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="20dp"
                    android:orientation="horizontal"
                    android:layout_gravity="center_horizontal"
                    android:gravity="center_vertical">
                    <View
                        android:layout_width="20dp"
                        android:layout_height="2dp"
                        android:background="@color/background_gray"/>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/black"
                        android:layout_marginLeft="5dp"
                        android:layout_marginRight="5dp"
                        android:textSize="12sp"
                        android:text="热门优惠"/>
                    <View
                        android:layout_width="20dp"
                        android:layout_height="2dp"
                        android:background="@color/background_gray"/>
                </LinearLayout>

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/home_rv_hot"
                    android:layout_width="wrap_content"
                    android:layout_height="200dp">
                </android.support.v7.widget.RecyclerView>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="10dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginBottom="10dp"
                    android:background="@color/background_gray"/>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="20dp"
                    android:orientation="horizontal"
                    android:layout_gravity="center_horizontal"
                    android:gravity="center_vertical">
                    <View
                        android:layout_width="20dp"
                        android:layout_height="2dp"
                        android:background="@color/background_gray"/>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/black"
                        android:layout_marginLeft="5dp"
                        android:layout_marginRight="5dp"
                        android:textSize="12sp"
                        android:text="艺届资讯"/>
                    <View
                        android:layout_width="20dp"
                        android:layout_height="2dp"
                        android:background="@color/background_gray"/>
                </LinearLayout>

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

            </LinearLayout>

        </RelativeLayout>

    </android.support.v4.widget.NestedScrollView>

代码中也进行了设置:

// 滑动优化
mHomeRvConvenient.setNestedScrollingEnabled(false);
mHomeRvHot.setNestedScrollingEnabled(false);
mHomeRvClassical.setNestedScrollingEnabled(false);
mHomeRvArticle.setNestedScrollingEnabled(false);
  • 写回答

5条回答

  • Mr丶Oops 2017-09-04 02:18
    关注

    图片说明

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置