【1】实现瀑布流,item乱跳
StaggeredGridLayoutManager manager = new StaggeredGridLayoutManager(2, RecyclerView.VERTICAL);
//解决item乱跳问题
manager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_NONE);
【2】瀑布流图片自适应
//Adapter中添加
//获取imageView
ImageView ivModel = helper.getView(R.id.iv_model_style);
ViewGroup.LayoutParams lp = ivModel.getLayoutParams();
int imgWidth = item.getWidth();
int imgHeight = item.getHeight();
int width = JUtils.getScreenWidth() / 2 - JUtils.dip2px(15);
int height = imgHeight * width / imgWidth;
lp.width = width;
lp.height = height;
//给imageview重新设置宽高
ivModel.setLayoutParams(lp);
【3】单条item刷新
adapter.notifyItemChanged(position, null);