View position in recyclerview with gridlayoutmanager - android

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

Related

Android Staggered Gridview Layout

have anyone done the same layout as fig. 1? i am currently using StaggeredGridLayoutManager but the result is fig 2. could anyone help me regarding this?
Ps tried using grid layout but it just copy the height of the largest height
Use GridLayoutManager instead of StaggeredGridLayoutManager for achieving same layout as fig. 1
GridLayoutManager creates the equal height grids.
val gridLayoutManager = GridLayoutManager(this, 2)
recyclerview.layoutManager = gridLayoutManager

Android GridLayoutManager horizontal scroll with 3 items

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)

set max rows 4 and columns to be dynamic in RecyclerView GridLayoutManager

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);

How remove spacing Horizontal GridLayoutManager recyclerview android

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.

How to implement horizontal gridlayoutmanager

How to implement horizontal gridlayoutmanager with recyclerview.
Fixed row count. and horizontal scroll.
Like this...
gridLayoutManager = new GridLayoutManager(getContext(), 1, GridLayoutManager.HORIZONTAL, false);
recyclerView.setLayoutManager(gridLayoutManager);
recyclerView.setHasFixedSize(true);
I try do this. but this is not show anything in item.
Implement RecyclerAdapter, ViewHolder.
Instantiate RecyclerAdapter, set its' adapter.
Specify ROWSCOUNT (there are 3 rows on your picture):
GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), ROWSCOUNT, GridLayoutManager.HORIZONTAL, false);
Set layout manager: recyclerView.setLayoutManager(gridLayoutManager);
Show your recycler view setContentView(recyclerView);
I've prepared a sample for you, check it out
I just add the affirmation. This picture might proof that Recyclerview with GridLayoutmanager is available for horizontal.

Categories

Resources