主函数里
mXrv.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
适配器
class MyViewHolder extends XRecyclerView.ViewHolder{
SimpleDraweeView sdv;
SimpleDraweeView sdv_below;
TextView name,place,videoName,liuyan;
/*为了 瀑布流 同城子布局*/
private RelativeLayout rl;
public MyViewHolder(View itemView) {
super(itemView);
sdv=itemView.findViewById(R.id.sdv);
sdv_below=itemView.findViewById(R.id.sdv_below);
name=itemView.findViewById(R.id.wenname);
place=itemView.findViewById(R.id.place);
videoName=itemView.findViewById(R.id.videoName);
liuyan=itemView.findViewById(R.id.liuyan);
/*瀑布流 改变宽高*/
rl = (RelativeLayout)itemView.findViewById(R.id.rl);
int width = ((Activity) rl.getContext()).getWindowManager().getDefaultDisplay().getWidth();
ViewGroup.LayoutParams params = sdv.getLayoutParams();
//设置图片的相对于屏幕的宽高比
params.width = width/2;
params.height = (int) (200 + Math.random() * 400) ;
sdv.setLayoutParams(params);
}