I have a GridLayoutManager which I need to be ordered first top to bottom and only then to the right
What I have now is
0 1 2
3 4 5
Ans what I want is
0 2 4
1 3 5
How do I achieve that?
Here's my code
layoutManager = GridLayoutManager(context, spanCount, LinearLayoutManager.VERTICAL, false)
Related
I have recyclerview with GridLayoutManager and I want 2 things:
3 items in screen
horizontal scroll
Issue
If I don't use horizontal scroll I can have 3 items in screen but yeah it's not horizontal, but if I add horizontal option to GridLayoutManager then it does not show 3 items in screen row.
Current code that gives me 3 items in row (but it's vertical)
laundriesRecycler.layoutManager = GridLayoutManager(context, 3)
Testing code that gives me horizontal scroll but not 3 items in row
laundriesRecycler.layoutManager = GridLayoutManager(context, 3, GridLayoutManager.HORIZONTAL, false)
layoutManager code
laundriesRecycler.layoutManager = GridLayoutManager(context, 3)
laundriesRecycler.adapter = NearLaundriesAdapter(context, list, useraddress)
I am using recyclerview with gridlayoutmanger with spancount 2 containing fixed 12 elements only in recyclerview.On tablets in landscape mode the empty space is remaining after the sixth element. I want to fill the empty space with the elements from second row. If space is there than then first row contain either 6, 7, 8 ,9 ... elements depends upon the remaining space.
Use FlexLayoutManger with recycler view :
RecyclerView recyclerView = (RecyclerView) context.findViewById(R.id.recyclerview);
FlexboxLayoutManager layoutManager = new FlexboxLayoutManager(context);
layoutManager.setFlexDirection(FlexDirection.COLUMN);
layoutManager.setJustifyContent(JustifyContent.FLEX_END);
recyclerView.setLayoutManager(layoutManager);
See this link
https://github.com/google/flexbox-layout#flexboxlayoutmanager-within-recyclerview
I want a grid view which adds elements in new row each time when the row count reach 4 it should start adding element in 1st row.
Let say I have 7 items in 1st image and add 2 more elements then it should add first element at last index of 2nd column and second element at 1 index of column 3
Let say I have 11 items in 2nd image and add 2 more elements then it should add first element at last index of 3rd column and second element at 1 index of column 4
Try this:
GridLayoutManager layoutManager =
new GridLayoutManager(getActivity(), 4);
layoutManager.setOrientation(RecyclerView.HORIZONTAL);
recyclerView.setLayoutManager(layoutManager);
try this
GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 4, GridLayoutManager.HORIZONTAL, false);
recycleView.setLayoutManager(gridLayoutManager);
I use recyclerview with grid layoutmanager
I don't add ItemDecoration
GridLayoutManager gridLayoutManager = new GridLayoutManager(TestResultActivity.this, 4, GridLayoutManager.HORIZONTAL, false);
gridLayoutManager.setAutoMeasureEnabled(true);
grid.setLayoutManager(gridLayoutManager);
But between two rows, have a row and I don't add it. I want to remove it.
I am using a recyclerview with gridlayoutmanager with 3 columns. How can I know in which column my view is?
I think it's just:
column = position % 3