zoukankan      html  css  js  c++  java
  • RecycleView 瀑布流滑动移位

    RecycleView StaggeredLayoutManager(瀑布流)滑动的时候,默认会出现item移动的问题,需以下来个步骤来解决:

      附上StaggeredLayoutManager中的一段源码:

        

     1 /**
     2      * Does not do anything to hide gaps.
     3      */
     4     public static final int GAP_HANDLING_NONE = 0;
     5 
     6     @Deprecated
     7     public static final int GAP_HANDLING_LAZY = 1;
     8 
     9     /**
    10      * When scroll state is changed to {@link RecyclerView#SCROLL_STATE_IDLE}, StaggeredGrid will
    11      * check if there are gaps in the because of full span items. If it finds, it will re-layout
    12      * and move items to correct positions with animations.
    13      * <p>
    14      * For example, if LayoutManager ends up with the following layout due to adapter changes:
    15      * <pre>
    16      * AAA
    17      * _BC
    18      * DDD
    19      * </pre>
    20      * <p>
    21      * It will animate to the following state:
    22      * <pre>
    23      * AAA
    24      * BC_
    25      * DDD
    26      * </pre>
    27      */
    28     public static final int GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS = 2;
    StaggeredLayoutManager

       1: 滑动中,不处理 gap:

       mStaggeredLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_NONE);

     2: 给每个 item,设置大小:

       viewHolder.cardView.setLayoutParams(layoutParams);

  • 相关阅读:
    Spring与MyBatis整合应用
    Spring与JDBC整合应用
    登录权限检查(SpringMVC)
    SpringMVC中文乱码问题
    SpringMVC异常处理
    SpringMVC注解应用
    Viewpager+fragment数据更新问题解析
    android adb 读写模式 挂载文件系统
    Android网络通信两种方法
    Win7、win2008中让IIS7支持asp的方法
  • 原文地址:https://www.cnblogs.com/SWDreaming/p/5180291.html
Copyright © 2011-2022 走看看