Android ListView that mimics a GridView with asymmetric items. Supports items with row span and column span

Last update: Jun 15, 2022

AsymmetricGridView

Android Arsenal Build Status

An Android custom ListView that implements multiple columns and variable sized elements.

Please note that this is currently in a preview state. This basically means that the API is not fixed and you should expect changes between releases.

Sample application:

Try out the sample application on Google Play

Gplay

Screenshots:

screenshot 1 screenshot 2 screenshot 3 screenshot 4

Usage

Version 2.0.0 includes a major breaking change to the AsymmetricGridViewAdapter. You now provide your own adapter to the AsymmetricGridViewAdapter constructor instead of extending it.

In your build.gradle file:

dependencies {
    implementation 'com.felipecsl.asymmetricgridview:library:2.0.1'
}

In your layout xml:

<com.felipecsl.asymmetricgridview.library.widget.AsymmetricGridView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/listView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

In your activity class:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    listView = (AsymmetricGridView) findViewById(R.id.listView);

    // Choose your own preferred column width
    listView.setRequestedColumnWidth(Utils.dpToPx(this, 120));
    final List<AsymmetricItem> items = new ArrayList<>();

    // initialize your items array
    adapter = new ListAdapter(this, listView, items);
    AsymmetricGridViewAdapter asymmetricAdapter =
        new AsymmetricGridViewAdapter<>(this, listView, adapter);
    listView.setAdapter(asymmetricAdapter);
}

Whenever your adapter changes (add or remove items), the grid will automatically reflect those changes by subscribing to your adapter changes.

Toggle to enable/disable reordering of elements to better fill the grid

// Setting to true will move items up and down to better use the space
// Defaults to false.
listView.setAllowReordering(true);

listView.isAllowReordering(); // true

Snapshots of the development version are available in Sonatype's snapshots repository.

Works with Android 2.3.x and above.

Caveats

  • Currently only has good support for items with rowSpan = 2 and columnSpan = 2. In the near future it will support different layout configurations.

  • It will work best if you don't have too many items with different sizes. Ideally less than 20% of your items are of special sizes, otherwise the library may not find the best way to accommodate all the items without leaving a lot of empty space behind.

  • Row layout is too complex, with many nested LinearLayouts. Move to a more flat layout with a custom ViewGroup possibly.

Contributing

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.

Copyright and license

Code and documentation copyright 2011-2015 Felipe Lima. Code released under the MIT license.

GitHub

https://github.com/felipecsl/AsymmetricGridView
Comments
  • 1. Having trouble implementing AsymmetricGridView with CursorAdapter

    I am having trouble implementing AsymmetricGridView because my app uses a CursorAdapter to populate views. For example:

    public class MyAdapter extends CursorAdapter {
    
        public MyAdapter(Context context, Cursor c, boolean autoRequery) {
            super(context, c, false);
        }
        @Override
        public void bindView(View v, Context con, Cursor c) {
        }
        @Override
        public View newView(Context con, Cursor c, ViewGroup vg) {
        }
    }
    

    I don't see any way to incorporate AGV in this scenario.

    Reviewed by suomi35 at 2014-09-02 15:57
  • 2. AsymmetricGridViewAdapter Constructor is different

    compile 'com.felipecsl.asymmetricgridview:library:1.1.0'

    I found this Constructor public AsymmetricGridViewAdapter(android.content.Context context, com.felipecsl.asymmetricgridview.library.widget.AsymmetricGridView listView, java.util.List items)

    But, in sample project, i found that, private AsymmetricGridViewAdapter<?> getNewAdapter() { return new AsymmetricGridViewAdapter(this, listView, adapter); }

    Doesn't match. Don't know how to use the library

    Reviewed by KingWu at 2015-04-15 09:04
  • 3. Specify row height

    Is it possible to specify a row height in Asymmetric grid view? I need 'x' dp for small square grids (2 cols in a row) and 'y' dp for one rectangular view (one col in a row). Is this possible?

    Reviewed by gayathri-nair03 at 2015-08-18 07:25
  • 4. Readme ambiguity - RowSpan = 2 and ColumnSpan = 2

    This seems to imply any size up to RowSpan=2, and ColSpan=2 is acceptable, because obviously RowSpan=1, ColSpan=1 is acceptable, so it implies that ColSpan=1,RowSpan=2 and vice-versa are also acceptable.

    You should make that clearer... or implement that!

    Reviewed by bemusementpark at 2015-08-12 06:40
  • 5. Simplified Constructor and usage

    I just thought that seeing as the Adapter is final and has a particular need for a reference to the View it was getting a bit verbose. This can be moved into the setAdapter and automatically wrapped by the AsymmetricGridViewAdapter under the hood. Then the developer doesn't have to know about AsymmetricGridViewAdapter.

    I also added a removeItem call in the clickItem handler which really shows off the adaptability of your library.

    I am assuming that developers have no need to access the AsymmetricGridViewAdapter directly. If that's incorrect ignore this pull request.

    Reviewed by bemusementpark at 2015-08-03 10:22
  • 6. Maven repository points to outdated library

    Using compile 'com.felipecsl:asymmetricgridview:1.0.+' currently points to 1.0.5-SNAPSHOT. The most recent build is 1.0.20-SNAPSHOT. Not sure if this is intentional, however I ran into some null pointer exceptions in 1.0.5-SNAPSHOT that seem fixed in 1.0.20-SNAPSHOT.

    Reviewed by ter0 at 2014-05-27 13:23
  • 7. Constructor and restoreState conflict

    Hi Felipe,

    When constructor is called with a Items array on onCreateView and the restoreState is launch next the getView method don't find new elements in the array (get -1), and the cells are not shown. May be a problem some bad attribute configuration on constructor ?

    Reviewed by tgamez at 2014-05-27 09:14
  • 8. Green background of row

    I have set setRequestedColumnCount(3);..If there is one image in the row it shows a green background of the row.I have not set green background anywhere.Why is that and how can i remove it?

    Reviewed by bkjbkjbnkj687698698 at 2015-08-05 04:40
  • 9. Cannot use AsymmetricGridView with an adapter that contains multiple view types

    When using an adapter with multiple view types (in my case 4), the overridden method getViewTypeCount() never gets called. The adapter only uses one view type in getView (the first one to be inflated). Please provide a fix for this. Thanks.

    Reviewed by supersume at 2015-05-20 06:08
  • 10. Cannot find AsymmetricGridView methods on AsymmetricGridView object

    Hello everybody, I tried and build a project starting from the AsymmetricGridView demo but I'm experiencing something strange: even if I import the lib as

    compile 'com.felipecsl:asymmetricgridview:1.0.+'

    in my build.gradle file, and I don't have any issue in instantiating the AsymmetricGridView object, when I try to call - for example - the setDebugging or setAllowReordering it simply does not resolve the methods :-/ It also does not exactly show me what I expect it to, but that's another story, I fear ;-)

    I declare the list as

    private AsymmetricGridView listView;

    and then instantiate it as

    listView = (AsymmetricGridView) findViewById(R.id.listView);

    but when I type listView.setDebugging(!listView.isDebugging()); the two methods are not resolved, even if the type of the listView object is correctly reported to be AsymmetricGridView.

    Does this issue ring some kind of bell in your head or is this something you've actually never seen before?

    Thank you Marco

    Reviewed by MarKco at 2014-04-24 07:58
  • 11. Update android 28, Fix CI

    • Update Gradle Wrapper to 4.6
    • Update TargetSdk to 28
    • Update Support Library 28.0.0
    • Replace all compile with implementation
    • Removed oraclejdk7 because Travis no longer supported (see travis-ci/travis-ci#7884). Already tried with openjdk7 but It have issue when download Gradle
    Reviewed by piruin at 2018-10-13 04:01
  • 12. Nested Scrolling is not Working?

    Nested Scrolling is not working in Asymmetric Grid View,when i am putting this list view inside Nested Scroll View then List view is not scrolling the whole content it is just scrolling the content inside list view.

    Reviewed by Abhilash1307 at 2019-10-11 10:46
  • 13. AssymetricRecyclerView : some cells configuration are not allowed

    I am using this library with AssymetricRecyclerView,

    I have a 3 columns grid. This configuration is not possible :

    problem

    I have added cells in this order :

    • width:1 height:2
    • width:2 height:1
    • width:1 height:1
    • width:1 height:1 The last cell never appear on screen.

    Hope you can help. Thank you

    Reviewed by ChannVincent at 2018-11-21 10:21
  • 14. scrollToPosition() scrollTo() restoreInstanceState() do not scroll and keep recycler at the top

    First thank you for this amazing library, it saves me a lot of time.

    I have tried to dig deeper into your code to understand why the scroll dos not work. The following methods do not scroll :

    • scrollToPosition()
    • scrollTo()
    • restoreInstanceState() I keep searching but I don't understand why. I think there is something I don't understand. Can you help ?
    Reviewed by ChannVincent at 2018-11-14 09:19
  • 15. Recycler view Endless Scroll for pagination, How should I do?

    Help me..

    Made from (Asymmetric in Grid form).

    however, It is difficult to add an RecyclerView Endless Scroll Paging function.

    I long for help. please.

    Reviewed by J-0-Min at 2018-08-17 02:25
Drag and drop GridView for Android
Drag and drop GridView for Android

DynamicGrid Drag and drop GridView for Android. Depricated It's much better to use solutions based on recycler view. For example https://github.com/h6

May 6, 2022
A GridView which can addHeaderView and addFooterView
A GridView which can addHeaderView and addFooterView

Please follow me on GitHub, I need your support Github: https://github.com/liaohuqiu twitter: https://twitter.com/liaohuqiu 中文版文档 GridView with Header

May 21, 2022
An Android GridView that can be configured to scroll horizontally or vertically

TwoWayGridView An Android GridView that can be configured to scroll horizontally or vertically. I should have posted this over a year and a half ago,

Feb 22, 2022
A Paging GridView with the same behavior as PagingListView.

PagingGridView PagingGridView has the ability to add more items on it like PagingListView does. Basically is a GridView with the ability to add more i

Jan 31, 2022
An Android custom ListView and ScrollView with pull to zoom-in.
An Android custom ListView and ScrollView with pull to zoom-in.

PullZoomView An Android custom ListView and ScrollView with pull to zoom-in. Features Set ZoomView enable Add HeaderView Custom ZoomView Parallax or N

Jun 18, 2022
[] A swipe menu for ListView.
[] A swipe menu for ListView.

SwipeMenuListView A swipe menu for ListView. Demo Usage Add dependency dependencies { compile 'com.baoyz.swipemenulistview:library:1.3.0' } Step 1

Jun 14, 2022
ListView with blur/parallax/sticky capabilities

BlurStickyHeaderListView What is BlurStickyHeaderListView? It is a custom ListView with a header that displays pictures from an URL. It then adds a ni

Feb 15, 2022
*** WARNING: This library is no longer maintained *** An easy way to add a simple 'swipe-and-do-something' behavior to your `RecyclerView` items. Just like in Gmail or Inbox apps.
*** WARNING: This library is no longer maintained *** An easy way to add a simple 'swipe-and-do-something' behavior to your `RecyclerView` items. Just like in Gmail or Inbox apps.

SwipeToAction An easy way to add a simple 'swipe-and-do-something' behavior to your RecyclerView items. Just like in Gmail or Inbox apps. Integration

May 20, 2022
An Android staggered grid view which supports multiple columns with rows of varying sizes.

AndroidStaggeredGrid ##Notice - Deprecated - 09-2015 This library has been deprecated. We will no longer be shipping any updates or approving communit

Jun 21, 2022
An Android Animation library which easily add itemanimator to RecyclerView items.
An Android Animation library which easily add itemanimator to RecyclerView items.

RecyclerView Animators RecyclerView Animators is an Android library that allows developers to easily create RecyclerView with animations. Please feel

Jun 21, 2022
Android library providing simple way to control divider items (ItemDecoration) of RecyclerView
Android library providing simple way to control divider items (ItemDecoration) of RecyclerView

RecyclerView-FlexibleDivider Android library providing simple way to control divider items of RecyclerView Release Note [Release Note] (https://github

Jun 24, 2022
A modified version of Android's experimental StaggeredGridView. Includes own OnItemClickListener and OnItemLongClickListener, selector, and fixed position restore.

StaggeredGridView Introduction This is a modified version of Android's experimental StaggeredGridView. The StaggeredGridView allows the user to create

Jun 15, 2022
Kotlin way of building RecyclerView Adapter 🧩. You do not have to write RecyclerView Adapters again and again and suffer from handling of different view types. Kiel will help you.

Kiel Kiel is a RecyclerView.Adapter with a minimalistic and convenient Kotlin DSL which provides utility on top of Android's normal RecyclerView.Adapt

Jun 21, 2022
A drag-and-drop scrolling grid view for Android

DraggableGridView¶ ↑ a drag-and-drop scrolling grid view for Android Including in your project¶ ↑ To start using DraggableGridView: Place libs/Draggab

May 3, 2022
A very easy-to-use and non-intrusive implement of Swipe to dismiss for RecyclerView.
A very easy-to-use and non-intrusive implement of Swipe to dismiss for RecyclerView.

RecyclerViewSwipeDismiss A very easy-to-use and non-intrusive implement of Swipe to dismiss for RecyclerView. Preview How to use Add these lines to yo

Jun 18, 2022
RecyclerView extension library which provides advanced features. (ex. Google's Inbox app like swiping, Play Music app like drag and drop sorting)
RecyclerView extension library which provides advanced features. (ex. Google's Inbox app like swiping, Play Music app like drag and drop sorting)

Advanced RecyclerView This RecyclerView extension library provides Google's Inbox app like swiping, Play Music app like drag-and-drop sorting and expa

Jun 15, 2022
👇 Easy Google Photos style multi-selection for RecyclerViews, powered by Kotlin and AndroidX.
👇 Easy Google Photos style multi-selection for RecyclerViews, powered by Kotlin and AndroidX.

Drag Select Recycler View This library allows you to implement Google Photos style multi-selection in your apps! You start by long pressing an item in

Jun 15, 2022
. Android library that integrate sticky section headers in your RecyclerView

recyclerview-stickyheaders Recyclerview-stickyheaders is an Android library that makes it easy to integrate section headers in your RecyclerView. Thes

Apr 28, 2022
An android library for section headers that stick to the top
An android library for section headers that stick to the top

StickyListHeaders StickyListHeaders is an Android library that makes it easy to integrate section headers in your ListView. These section headers stic

Jun 15, 2022