最佳答案
如果 max columns 是两个,那将非常简单。对于占据整个宽度的 View ,setFullSpan(true) 就像在 Recyclerview Adapter 的 BindView 方法中一样
//rlm is RecyclerView.LayoutManager passed in constructor or setter in adapter
if (rlm instanceof StaggeredGridLayoutManager) {
StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams();
/*
* to make View to occupy full width of the parent
*/
layoutParams.setFullSpan(true);
}
关于android - 交错网格布局管理器动态列数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36218787/