How to show an asymmetric grid of images in android
Asked Answered
Z

0

6

I have to show images in an asymmetric grid dynamically - setting both rowSpan(height) and colSpan(width)(Supporting Android 10+). I have tried the following approaches

Approaches tried

  1. RecyclerView with GridLayoutManager With this, we can change only the width of an item(colSpan)(when the GridLayoutManager orientation is VERTICAL). We cannot change height(rowSpan)

  2. RecyclerView with StaggeredGridLayoutManager It supports horizontal & vertical layout as well as an ability to layout children in reverse. But as with the GridLayoutManager, we can only set either the rowSpan or the colSpan but not both(Depending on it's orientation

  3. TwoWayView This seemed like an ideal solution. But the library has a problem with latest versions of Android support library https://github.com/lucasr/twoway-view/issues/266. And we are using Android support library 23.3.2 in our project.

  4. AsymmetricGridView The author of the library has mentioned a caveat "Currently only has good support for items with rowSpan = 2 and columnSpan = 2". I am looking for a library that supports other row and column spans

  5. GridLayout This is only for Android 14+. I am looking at a solution which supports Android 10+

I have looked at the following Stack Overflow questions

No good example about RecyclerView and StaggeredGridLayoutManager in Android Docs

How to create AsymmetricGridView with different image sizes in row

Any help is greatly appreciated.

Zwick answered 9/7, 2016 at 13:54 Comment(1)

© 2022 - 2024 — McMap. All rights reserved.