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

Overview

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.

Comments
  • Having trouble implementing AsymmetricGridView with CursorAdapter

    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.

    opened by suomi35 11
  • AsymmetricGridViewAdapter Constructor is different

    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

    opened by KingWu 5
  • Specify row height

    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?

    opened by gayathri-nair03 4
  • Readme ambiguity - RowSpan = 2 and ColumnSpan = 2

    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!

    opened by bemusementpark 4
  • Simplified Constructor and usage

    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.

    opened by bemusementpark 4
  • Maven repository points to outdated library

    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.

    opened by ter0 4
  • Constructor and restoreState conflict

    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 ?

    opened by tgamez 4
  • Green background of row

    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?

    opened by bkjbkjbnkj687698698 3
  • Cannot use AsymmetricGridView with an adapter that contains multiple view types

    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.

    opened by supersume 3
  • Cannot find AsymmetricGridView methods on AsymmetricGridView object

    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

    opened by MarKco 2
  • Update android 28, Fix CI

    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
    opened by piruin 1
  • Nested Scrolling is not Working?

    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.

    opened by Abhilash1307 0
  • AssymetricRecyclerView : some cells configuration are not allowed

    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

    opened by ChannVincent 0
  • scrollToPosition() scrollTo() restoreInstanceState() do not scroll and keep recycler at the top

    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 ?
    opened by ChannVincent 0
  • Recycler view Endless Scroll for pagination, How should I do?

    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.

    opened by J-0-Min 1
Owner
Felipe Lima
🇧🇷
Felipe Lima
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

Alex Askerov 920 Dec 2, 2022
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

Huqiu Liao 1.3k Nov 30, 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,

Jess Anders 656 Jan 9, 2023
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

Nicolas Jafelle 279 Dec 29, 2022
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

Frank-Zhu 2.3k Dec 26, 2022
[] 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

星一 3.5k Dec 16, 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

null 129 Oct 26, 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

Etsy, Inc. 4.8k Dec 29, 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.

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

Victor Calvello 223 Nov 16, 2022
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

Daichi Furiya 11.2k Jan 5, 2023
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

Yoshihito Ikeda 2.4k Dec 18, 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

Maurycy Wojtowicz 1.7k Nov 28, 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

ibrahim yilmaz 370 Jan 2, 2023
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

Tom Quinn 565 Dec 27, 2022
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

xcodebuild 431 Nov 23, 2022
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

Haruki Hasegawa 5.2k Dec 23, 2022
👇 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

Aidan Follestad 1.9k Dec 7, 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

null 968 Nov 10, 2022
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

Emil Sjölander 5.5k Jan 2, 2023