How can we display RecyclerView
items side by side. i tried to do this by using FlowLayoutManager
and FlexboxLayoutManager
but it is showing in list format only here is the code with FlowLayoutManager
:
FlowLayoutManager flowLayoutManager = new FlowLayoutManager();
flowLayoutManager.setAutoMeasureEnabled(true);
listView.setLayoutManager(flowLayoutManager);
madapter = new testingAdapter(Quran_e_Kareem.this,surah1);
listView.setAdapter(madapter);
here is the code with FlexboxLayoutManager:
FlexboxLayoutManager flexboxLayoutManager = new FlexboxLayoutManager(getApplicationContext());
// Set flex direction.
flexboxLayoutManager.setFlexDirection(FlexDirection.ROW);
flexboxLayoutManager.setFlexWrap(FlexWrap.WRAP);
flexboxLayoutManager.setAlignItems(AlignItems.FLEX_START);
flexboxLayoutManager.setJustifyContent(JustifyContent.FLEX_START);
listView.setLayoutManager(flexboxLayoutManager);
madapter = new testingAdapter(Quran_e_Kareem.this,surah1);
listView.setAdapter(madapter);
I am getting result list this
But i want to get this way
Any help is appreciated.
Use ChipsLayoutManager use following lib helps me to do same
Please follow the below code and make your adapter textview wrap content may it will solve your problem.
Add into xml like this:
try this
set orientation of linearlayoutmanager for recyclerview