2022年4月6日 星期三

[Android] RecyclerView 瀑布流(方塊List 橫跨方式)


int columnCount = 3;
int spanCount = 2;
GridLayoutManager manager = new GridLayoutManager(context, columnCount,
    StaggeredGridLayoutManager.VERTICAL, false);
manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup(){

    @Override
    public int getSpanSize(int position) {
        if({判斷條件}){
           return spanCount;
        }
        return 1;
    }
});

deviceView.setLayoutManager(manager);