Questions tagged [gridlayoutmanager]

A RecyclerView.LayoutManager implementations that lays out items in a grid.

A RecyclerView.LayoutManager implementations that lays out items in a grid. More info on the docs: https://developer.android.com/reference/android/support/v7/widget/GridLayoutManager.html

403 questions
320
votes
33 answers

Android Recyclerview GridLayoutManager column spacing

How do you set the column spacing with a RecyclerView using a GridLayoutManager? Setting the margin/padding inside my layout has no effect.
Nick H
  • 8,897
  • 9
  • 41
  • 64
308
votes
8 answers

Simple Android grid example using RecyclerView with GridLayoutManager (like the old GridView)

I know that RecyclerView has replaced the functionality of the old ListView and GridView. I am looking for a very basic example that shows a minimal grid setup using RecyclerView. I am not looking for long tutorial style explanations, just a minimal…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
126
votes
14 answers

RecyclerView GridLayoutManager: how to auto-detect span count?

Using the new GridLayoutManager: https://developer.android.com/reference/android/support/v7/widget/GridLayoutManager.html It takes an explicit span count, so the problem now becomes: how do you know how many "spans" fit per row? This is a grid,…
111
votes
13 answers

Android add spacing below last element in recyclerview with gridlayoutmanager

I am trying to add spacing below the last element row in RecyclerView with GridLayoutManager. I used custom ItemDecoration for this purpose with bottom padding when its last element as follows: public class SpaceItemDecoration extends…
pratsJ
  • 3,369
  • 3
  • 22
  • 41
105
votes
3 answers

Set span for items in GridLayoutManager using SpanSizeLookup

I want to implement grid-like layout with section headers. Think of https://github.com/TonicArtos/StickyGridHeaders What I do now: mRecyclerView = (RecyclerView) view.findViewById(R.id.grid); mLayoutManager = new GridLayoutManager(getActivity(),…
75
votes
9 answers

Square layout on GridLayoutManager for RecyclerView

I try to make a grid-layout with square images. I thought that it must be possible to manipulate the GridLayoutManager by manipulating onMeasure to do a super.onMeasure(recycler, state, widthSpec, widthSpec); instead of super.onMeasure(recycler,…
Paul Woitaschek
  • 6,717
  • 5
  • 33
  • 52
71
votes
4 answers

How to center RecyclerView items horizontally with vertical GridLayoutManager

I have a vertical RecyclerView using a GridLayoutManager. I want each column to be centered, but the columns begin all the way on the left. In the following picture you can see what I'm talking about. I used the ugly color scheme to illustrate the…
JackTheCripple
  • 783
  • 1
  • 5
  • 8
58
votes
18 answers

(Smooth)ScrollToPosition doesn't work properly with RecyclerView

I'm using basic RecyclerView with GridLayoutManager. I observed that nor smoothScrollToPosition nor scrollToPosition works properly. a) when using smoothScrollToPosition I often receive error from RecyclerView "RecyclerView﹕ Passed over target…
52
votes
5 answers

RecyclerView 2 Columns with CardView

I have a problem with my layout. I'm trying to do something like this: For now, i have a RecyclerView with a CardView inside it. in the CardView I have put an ImageView and a TextView but I don't know why but the CardView is more height than…
50
votes
4 answers

Drag and drop items in RecyclerView with GridLayoutManager

What I want to achieve: Have a RecyclerView with GridLayoutManager that supports drag'n'drop and that rearranges the items while dragging. Side note: First time developing anything with drag and drop. There are a lot of topics on how to achieve this…
45
votes
4 answers

android - how to catch Drop action of ItemTouchHelper which is used with RecyclerView

I have a problem with ItemTouchHelper of RecyclerView. I am making a game. The game board is actually a RecyclerView. RecyclerView has GridLayoutManager with some span count. I want to implement drag & drop recyclerview's items. Any item can…
okarakose
  • 3,692
  • 5
  • 24
  • 44
41
votes
9 answers

How to set the height of an item row in GridLayoutManager

My Recycler Item which inflate in onCreateViewHolder
Kunal
  • 953
  • 1
  • 10
  • 14
38
votes
2 answers

RecyclerView GridLayoutManager with full width header

I'm using a very helpful example here to show a RecyclerView and a GridLayoutManager to show a grid with a header. It looks pretty good, but my graphic designer wants the header item to take up the full width of the RecyclerView. Right now there is…
Kibi
  • 1,860
  • 1
  • 29
  • 39
35
votes
10 answers

How to make RecyclerView scroll smoothly?

This is more like a generic question, but after lot of search and try I am not able to understand why this is so difficult to achieve. This is the closest answer I can find but still unable to implement. To be specific I am using RecyclerView with…
33
votes
5 answers

How can I fill RecyclerView with GridLayoutManager from right to left

I'm trying to fill some data into a RecyclerView with GridLayoutManager: GridLayoutManager layoutManager = new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false); This will fill the data into the grid from left to right. The first item…
1
2 3
26 27