Giter Site home page Giter Site logo

mobileiq / asymmetricgridview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from felipecsl/asymmetricgridview

0.0 26.0 0.0 4.76 MB

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

Home Page: http://felipecsl.com/AsymmetricGridView

License: MIT License

Groovy 1.12% Java 98.41% Shell 0.47%

asymmetricgridview's Introduction

AsymmetricGridView

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

In your build.gradle file:

repositories {
    maven { url 'https://github.com/felipecsl/m2repository/raw/master/' }
    // ...
}

dependencies {
    // ...
    compile 'com.felipecsl:asymmetricgridview:1.0.+'
}

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);

    listView.setAdapter(adapter);
}

Supports resetting and appending more elements into the adapter:

// Will append more items at the end of the adapter.
listView.getAdapter().appendItems(moreItems);

// resetting the adapter items. Will clear the adapter
// and add the new items.
listView.getAdapter().setItems(items);

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

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-2014 Felipe Lima. Code released under the MIT license.

asymmetricgridview's People

Contributors

felipecsl avatar luciofm avatar paul-simmonds avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.