Help me create recyclerview with 3 colums, like a show picture belowenter image description here
CodePudding user response:
Simply use span count with Grid layout manager, here is example
In XML:
app:spanCount="3"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
in JAVA:
recView.setLayoutManager(new GridLayoutManager(this,3,RecyclerView.VERTICAL,false));
in KOTLIN:
recView.layoutManager = GridLayoutManager(this,3,RecyclerView.VERTICAL,false)
CodePudding user response:
recyclerView.setLayoutManager(new GridLayoutManager(mContext, 3)); //GridLayoutManager(context, nºcolumns) recyclerView.setAdapter(yourAdapter);