1.瀑布流时需要第一个占满一格时
@Override
public void onViewAttachedToWindow(BaseClearViewHolder holder) {
super.onViewAttachedToWindow(holder);
// 使第一个topic的item占满一行
int index = holder.getLayoutPosition();
// 是topic占满一行
if (getItemViewType(index) == VIDEO_TOPIC) {
ViewGroup.LayoutParams lp = holder.itemView.getLayoutParams();
if (lp != null && lp instanceof StaggeredGridLayoutManager.LayoutParams) {
StaggeredGridLayoutManager.LayoutParams sLp = ((StaggeredGridLayoutManager.LayoutParams) lp);
sLp.setFullSpan(true);
}
}
}
2.瀑布流时滑到出多组数据后快速向回顶部,会有item交换位置的现象
解决方法一.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_NONE) 并没解决,会导致最上面空出一个item.
有效果的方法.局部更新数据.
adapter.notifyItemRangeInserted()而不使用notifyDateSetChange()
网友评论