Questions tagged [android-gridlayout]

GridLayout is one of Android's ViewGroup subclasses that places its children in a rectangular grid.

GridLayout is mainly useful when we want to show data in a grid like layout. This layout can be used to build applications like image viewer, audio or video players in order to show elements in a grid manner.

The grid is composed of a set of infinitely thin lines that separate the viewing area into cells. GridLayout supports both row and column spanning and arbitrary forms of alignment within each cell group.

An example using the GridLayout can be found on the Android developers blog.

725 questions
254
votes
25 answers

GridLayout (not GridView) how to stretch all children evenly

I want to have a 2x2 grid with a buttons inside. This is only ICS so I am trying to use the new GridLayout given. Here's the XML of my layout:
dnkoutso
  • 6,041
  • 4
  • 37
  • 58
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,…
126
votes
5 answers

GridLayout and Row/Column Span Woe

The Android Developers Blog post introducing GridLayout shows this diagram of how spans impact automatic index allocation: I am attempting to actually implement that using a GridLayout. Here is what I have so…
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
79
votes
8 answers

GridLayoutManager - how to auto fit columns?

I have a RecyclerView with a GridLayoutManager that displays Card Views. I want the cards to rearrange according to the screen size (the Google Play app does this kind of thing with its app cards). Here is an example: Here is how my app looks at…
70
votes
9 answers

Changing number of columns with GridLayoutManager and RecyclerView

Inside my fragment I'm setting my GridLayout in the following way: mRecycler.setLayoutManager(new GridLayoutManager(rootView.getContext(), 2)); So, I just want to change that 2 for a 4 when the user rotates the phone/tablet. I've read about…
55
votes
5 answers

Add space to the end of the RecyclerView

I have a recyclerview with a gridlayout. What I want is when the user scrolls to the end of the list (see my bad mockup), there should be an empty space with a height of 50dp, which isn't the same dimensions as my grid. Note that this space is only…
54
votes
6 answers

GridLayout Column width

I have 2 columns in my GridLayout. What I want to do is make those columns take up half of the width of the screen each and then have its child contents fill their own cells width/height. I tried setting the children to fill_parent but that just…
bwoogie
  • 4,339
  • 12
  • 39
  • 72
45
votes
4 answers

Android - Difference between Gridlayout and Staggered Gridlayout

I am working in android material design api & want to display some data in grid format. I tried both GridLayout and StaggeredGridlayout and both look same. For general information, i want to ask what is the difference between Gridlayout and…
44
votes
14 answers

Textview with long text pushes out other views in GridLayout despite ellipsize=end

My problem is very similar to How to get a layout where one text can grow and ellipsize, but not gobble up the other elements on the layout, but read on below why I can't use TableLayouts as proposed there. I'm trying to create a listview row that…
Stefan Frye
  • 2,007
  • 1
  • 20
  • 24
36
votes
5 answers

How do I set android:layout_columnWeight="1" programmatically to an element in an android support v7 Gridlayout

I'm trying to build a GirdLayout programmatically with 2 columns and I want these columns to have equal width set at half the width of the screen. I figured out you can do this since API 21 or with the support v7 GirdLayout view. I see examples…
hans_dc
  • 529
  • 1
  • 5
  • 15
36
votes
3 answers

gridView with different cells sizes, pinterest style

Background GridView is a class that extends AdapterView , which means it shows cells in a grid-style efficiently, recycling old views to be shown as new ones when the user scrolls it. The problem Sometimes, you would want to get a special UI, which…
35
votes
2 answers

Android GridLayout Equal Column Widths

Is it really not possible to easily force equal column widths in an Android GridLayout? Trying the obvious layout...
Boulder Keith
  • 535
  • 1
  • 5
  • 10
28
votes
2 answers

Android: GridLayout spacing between items

I have a grid layout which is filled with buttons. I want the buttons to be more distant from each other, what code should I write? I tried to search for it but only found a solution for GridView, not GridLayout.
Ralph
  • 435
  • 1
  • 5
  • 13
25
votes
5 answers

android.support.v7.widget.GridLayout cannot get it to work

I have an android project which utilizes GridLayout in most of its menus and screens. The problem however is that GridLayout is supported from API 14 and onwards. Since I want to make the application available to older version of android as well, I…
24
votes
4 answers

Trying to replicate GridLayout column alignment with ConstraintLayout

I'm new to ConstraintLayout, and I'm trying to replicate the same grid behavior offered by GridLayout with ConstraintLayout. Specifically, I want to design a two columns grid. The first column width should be as narrow as possible, while the second…
1
2 3
48 49