嵌套滚动视图无法使用RecyclerView Android平稳滚动 [英] Nested scroll View not scrolling smoothly with recyclerview android

查看:65
本文介绍了嵌套滚动视图无法使用RecyclerView Android平稳滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用嵌套滚动视图包装recyclerview和其他按钮.它工作得很好,但我注意到滚动时不流畅.请指导如何使滚动平滑.

I am using Nested Scrollview to wrap the recyclerview and other button. It worked perfectly but I noticed that when I scrolled it not smooth. Please guide how to make scrolling smooth.

 <android.support.v4.widget.NestedScrollView
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:id="@+id/scrollView"
                        android:fillViewport="true">
                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:orientation="vertical">
                            <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content">
                                <Button
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_action_filter"
                                    android:text="Filter"
                                    android:id="@+id/btn_filter"
                                    android:layout_margin="0dp"
                                    android:layout_weight="1"
                                    />
                                <Button
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_action_sortbyt"
                                    android:layout_margin="0dp"
                                    android:text="Sort By"
                                    android:id="@+id/btn_sortby"
                                    android:layout_weight="1"/>
                            </LinearLayout>
                            <android.support.v7.widget.RecyclerView
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:id="@+id/lastest_product_list"
                                android:nestedScrollingEnabled="false"
                                android:isScrollContainer="false">
                            </android.support.v7.widget.RecyclerView>
                        </LinearLayout>
                    </android.support.v4.widget.NestedScrollView>

推荐答案

根据Android文档,android:nestedScrollingEnabled="false"可以使用,但只能在Android API level >= 21上使用.

As per Android documentation android:nestedScrollingEnabled="false" works, but only on Android API level >= 21.

如果您还希望支持API 21以下的设备,请使用以下命令:

If you want to support devices below API 21 as well, use the following:

ViewCompat.setNestedScrollingEnabled(recyclerView, false);

这篇关于嵌套滚动视图无法使用RecyclerView Android平稳滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆