我如何使动态列数RecyclerView
using StaggeredGridLayoutManager
。我已经有工作了RecyclerView
。这是我需要做的屏幕:
如果最大列是两个,那就很简单了。对于占据整个宽度的视图,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);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)