NestedScrollView + Recyclerview下滑卡顿解决方法

  

大家在进行安卓开发用到NestedScrollView + Recyclerview的时候,经常出现的情况就是加载下滑的时候没有任何问题,很流畅,但是在下滑以后明显出现了卡顿的情况,小编根绝这个问题,给大家再来的解决方法,一起来学习下。

  

我们先来看下这个BUG的表现:
  1.滑动卡顿,
  2.加载下滑时流畅,下滑时明显的卡顿
  3 .进入页面时直接加载RecyclerView部分的内容(这里我理解为控件惯性,不知道对不对- - - - - - -尴尬! ! ! ! ! !)
  下面我们一一来解决这些问题

  

在开发项目中,涉及到到商品详情页,新闻详情页等的页面时,通常情况下,商品详情页的底部会附上商品的评论或者是相关商品的的推荐,或者是相关性的文章。那么我们就会用到列表的RecyclerView,在头部可能是一些比较复杂的多种界面,可能采用比较简单的方法来处理,那就是NestedScrollView + RecyclerView,这这种方式比较直观和方便操作,比如像下面的代码

        & lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比;   & lt; android.support.v4.widget.NestedScrollView   xmlns: android=" http://schemas.android.com/apk/res/android "   xmlns:应用=" http://schemas.android.com/apk/res-auto "   android: id=癅 + id/scrollView_comment”   android: layout_width=" match_parent "   android: layout_height=" match_parent "   比;      LinearLayout & lt;   android: layout_width=" match_parent "   android: layout_height=" match_parent "   面向android:=按怪薄北?   .....此处省略   LinearLayout & lt;   android: layout_width=" match_parent "   android: layout_height=" 44 dp "   android:重力="中心"的在      LinearLayout & lt;   android: layout_width=" wrap_content "   android: layout_height=皐rap_content”比;      & lt; ImageView   android: layout_width=" 20 dp”   android: layout_height=" 20 dp”   android: src=" https://www.yisu.com/zixun/@color text_msg_33 "/比;      & lt; TextView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_marginLeft=" 12 dp "   android: layout_marginRight=" 12 dp "   android:文本=" 1 "   android:输入textColor=" # 8 c8c8c "   android: textSize=" 15 sp”/比;      & lt; ImageView   android: layout_width=" 20 dp”   android: layout_height=" 20 dp”   android: src=" https://www.yisu.com/zixun/@color text_msg_33 "/比;   & lt;/LinearLayout>      & lt; TextView   android: layout_width=" wrap_content "   android: layout_height=" 20 dp”   android: layout_marginRight=" 10 dp”   android:背景=" @drawable/bg_shop_card”   android:重力="中心"   android: paddingLeft=" 8 dp "   android: paddingRight=" 8 dp "   android:文本="加入购物车”   android:输入textColor=" @color/白”   android: textSize=" 14 sp "/比;   & lt;/LinearLayout>      & lt;视图   android: layout_width=" match_parent "   android: layout_height=" 10 dp”   android:背景=" # f2f2f2 "/比;      LinearLayout & lt;   android: layout_width=" match_parent "   android: layout_height=" 35 dp”   android:重力=癱enter_vertical”比;      & lt; TextView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_marginLeft=" 11 dp "   android:文本="用户评价”   android:输入textColor=" # 666666 "   android: textSize=" 13 sp "/比;      & lt; TextView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_marginLeft=" @dimen/line_1px”   android: layout_marginRight=" 20 dp”   android:文本=" (21313)"   android:输入textColor=" # 666666 "   android: textSize=" 13 sp "/比;      & lt;/LinearLayout>      & lt;视图   android: layout_width=" match_parent "   android: layout_height=" 0.5 dp "   android:背景=" # dcdcdc "/比;      & lt; android.support.v7.widget.RecyclerView   android: id=癅 + id/recycler_seller_comment”   android: layout_width=" match_parent "   android: layout_height=" match_parent "   android: descendantFocusability=" blocksDescendants "   android: nestedScrollingEnabled=" false "/比;      & lt; TextView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android:文本="查看更多”   android:输入textColor=" # 8 c8c8c "   android: textSize=" 13 sp "/比;   & lt;/LinearLayout>   & lt;/android.support.v4.widget.NestedScrollView>

NestedScrollView + Recyclerview下滑卡顿解决方法