AsymmetricGridView


Source link: https://github.com/felipecsl/AsymmetricGridView

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

Screenshots:

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 {

  compile '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.

Resources

A Simple Pcm / Wav audio recorder with nice api.

This is an Android library which can be used to apply different Filters/Effects on videos.

A night model lib to change app's night theme easy. You do not need to restart Activity.

A messaging library for Android.

A cool customizable loading animation with Dots.

A simple and easy-to-use scroll number widget.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes