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

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 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果