RecyclerView 相关

1、RecyclerView嵌套RecyclerView布局,子RecyclerView表格布局数量不足时,会产生大量空白地方,这个时候需要点击空白地方产生点击事件,但是不能影响RecyclerView item 和子RecyclerView item两个的点击事件,需要做如下配置。imgRv是子RecyclerView布局,llContent为imgRv父布局。

   imgRv.setOnTouchListener(new View.OnTouchListener() {
                //处理点击到RecyclerView上面无反应
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (event.getAction() == MotionEvent.ACTION_UP) {
                        float scaledHorizontalScrollFactor = ViewConfigurationCompat.getScaledHorizontalScrollFactor(ViewConfiguration.get(mContext), mContext);
                        float scaledVerticalScrollFactor = ViewConfigurationCompat.getScaledVerticalScrollFactor(ViewConfiguration.get(mContext), mContext);
                        if(scaledHorizontalScrollFactor>0||scaledVerticalScrollFactor>0){
//这里调用某个逻辑点击事件
                            llContent.performClick();
                            return true;
                        }
                    } return false;
                } });

2、RecyclerView 图片刷新闪烁的问题:
①、对列表进行设置

   ((SimpleItemAnimator)rvMore.getItemAnimator()).setSupportsChangeAnimations(false);

      rvMore.setItemAnimator(null);

②、对图片加载进行tag判断

   if (!entity.getVideo().getVideoCoverPath().equals(ivIconType.getTag(R.drawable.default_news))) {

     GlideUtils.loadCustomRound(context, entity.getVideo().getVideoCoverPath(),ivIconType,4);

  ivIconType.setTag(R.drawable.default_news, entity.getVideo().getVideoCoverPath());

}

你可能感兴趣的:(RecyclerView 相关)