实现效果
image.png
代码实现
val sglm = StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL)
goodsAdapter = SelfUneGoodsAdapter(this,skuList)
goodsAdapter?.setAdapterClickListener(this)
with(rvList){
layoutManager = sglm
addItemDecoration(GridSpaceItemDecoration(2,10,10))
adapter = goodsAdapter
}
注意点:
1:StaggeredGridLayoutManager
实现流式布局的layoutManager
2:adapter中的布局(View)的高度使用wrap_content
实现以上两点就可以实现流式布局了
网友评论