NestedScrollView+RecyclerView 滑动卡顿简单解决方案
2017-12-15 21:00
2256 查看
这个是在工作中发现的问题
以下xml是当前布局:<code>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
<LinearLayout
android:id="@+id/linerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</code>
NestedScrollView中包含了LinearLayout,LinearLayout包含了一系列的组件,其中包括RecyclerView,RecyclerView和NestedScrollView都有滚动事件,这种情况下进行滑动操作,fling的操作体验很差,几乎就是手指离开的时候,滑动停止.
以下xml是改动后的布局:
<android.support.v7.widget.RecyclerView android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="match_parent" android:nestedScrollingEnabled="false" />
android:nestedScrollingEnabled="false"
官方文档:
Enable or disable nested scrolling for this view.
If this property is set to true the view will be permitted to initiate nested scrolling operations with a compatible parent view in the current hierarchy. If this view does not implement nested scrolling this will have no effect. Disabling nested scrolling while a nested scroll is in progress has the effect of stopping the nested scroll.
这里设置为false,放弃自己的滑动,交给外部的NestedScrollView处理,就没有出现卡顿的现象了,并且有fling的效果
相关文章推荐
- NestedScrollview 嵌套 RecyclerView 滑动卡顿,ScrollView 嵌套 RecyclerView 冲突 解决方案
- 关于NestedScrollView + RecyclerView页面载入时总是滑动到最底部
- 解决NestedScrollView 嵌套 RecyclerView 滑动没有惯性,直接停顿的现象
- 解决NestedScrollView中嵌套RecyclerView滑动冲突问题
- ScrollView嵌套RecyclerView时滑动出现的卡顿解决方案
- 使用NestedScrollView+ViewPager+RecyclerView+SmartRefreshLayout打造酷炫下拉视差效果并解决各种滑动冲突
- NestedScrollView+RecyclerView优雅的解决滑动冲突问题
- 解决NestedScrollView 嵌套 RecyclerView出现的滑动冲突问题
- NestedScrollView+RecyclerView优雅的解决滑动冲突问题
- NestedScrollView+Recyclerview下滑卡顿解决方法
- 解决NestedScrollView 嵌套 RecyclerView出现的卡顿,上拉刷新无效
- 记个小问题:NestedScrollView+RecyclerView冲突,滑动黏连
- 使用NestedScrollView+ViewPager+RecyclerView+SmartRefreshLayout打造酷炫下拉视差效果并解决各种滑动冲突
- Android滑动冲突解决方式(下拉刷新上拉加载更多,适配RecyclerView/ListView/ScrollView)
- CoordinatorLayout + AppBarLayout + NestScrollView 向上滑动卡顿问题解决方案
- NestedScrollView嵌套RecyclerView时滑动不流畅问题的解决办法
- Android ScrollView里嵌套RecyclerView时,在RecyclerView上滑动时出现卡顿(冲突)的现象
- RecycleViewScrollHelper--RecyclerView滑动事件检测的辅助类
- Android Scrollview嵌套RecyclerView导致滑动卡顿问题解决
- 解决ScrollView嵌套RecyclerView 滑动卡顿和嵌套多个RecyclerView 显示不全的问题