TwoWayGridView


Source link: https://github.com/jess-anders/two-way-gridview

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, but never got around to it. I needed a grid view that in portrait would scroll vertically, but in landscape, would scroll horizontally. I thought I could try hacking up the Gallery, but that never works out well, and if GridView could really be configured to scroll any direction, it would just be so much easier.

So I built it one weekend. Lots of left, right, top, bottom changes, but the end result is a really useful UI widget.

Feel free to use it in your apps, according to the Apache 2.0 license. Also feel free to fork it and improve it. You could fairly easily create a horizontal listview by extending TwoWayAbsListView

Usage

The TwoWayGridView can be used as a drop-in replacement for the normal Android GridView. It just has a few more configurable attributes:

  • scrollDirectionPortrait (vertical | horizontal) The direction the grid will scroll when the device is in portrait orientation
  • scrollDirectionLandscape (vertical | horizontal) The direction the grid will scroll when the device is in landscape orientation
  • numRows (integer) Number of rows in grid view when in horizontal scrolling mode
  • verticalSpacing (dimension) Height of vertical spacing between grid rows
  • rowHeight (dimension) Height of each grid row

Here is an example from the demo layout where it is configured to scroll vertically in portrait and horizontally in landscape :

<?xml version="1.0" encoding="utf-8"?> <com.jess.ui.TwoWayGridView
  xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"
  android:background="#E8E8E8"
  android:id="@+id/gridview"
  android:layout_width="fill_parent"

android:layout_height="fill_parent"
  app:cacheColorHint="#E8E8E8"
  app:columnWidth="80dp"
  app:rowHeight="80dp"
  app:numColumns="auto_fit"
  app:numRows="auto_fit"
  app:verticalSpacing="16dp"
  app:horizontalSpacing="16dp"
  app:stretchMode="spacingWidthUniform"
  app:scrollDirectionPortrait="vertical"
  app:scrollDirectionLandscape="horizontal"
  app:gravity="center"/> 

Resources

A library that implements Google Play like PersistentSearch view.

  • 3 modes: Toolbar with drawer button, MenuItem and Toolbar with back button
  • MenuItem mode reveal animation
  • Voice recognition support.
  • Use android.support.v7.widget.CardView to draw background and shadow, you can set persistentSV_searchCardElevation to modify shadow size.

JPagerSlidingTabStrip - deeply modified PagerSlidingTabStrip.

  • Added 3 tabStyles and possibility to customize tabStyles (JTabStyle).
  • Added possibility to show unread messages (like weichat).

This demo aims shows practical way of clean architecture, MVP.

Android floating window permission compatibility library.

Create navigation drawers in your Activities and Fragments without having to write any XML, in pure Kotlin code, with access to all the features of the original library: all sorts of menu items, badges, account headers, and more.

Android RecyclerView sticky header list / grid layout manager. It supports header shadows, smooth scroll, individual sticky header state and scrollbars. Can be used as simple list layout, using one column.

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