SimpleItemDecoration


Source link: https://github.com/dgreenhalgh/simple-item-decoration

#SimpleItemDecoration

Currently in active development

SimpleItemDecoration is a simple library for adding dividers and offsets to Android's RecyclerView using RecyclerView.ItemDecoration.

It can be used to add both interior dividers and start/end offsets to RecyclerViews using LinearLayoutManager or GridLayoutManager.

###Usage

All of the ItemDecorations included can be added to your RecyclerView by calling RecyclerView#addItemDecoration(), passing in your desired ItemDecoration as a parameter.

####DividerItemDecoration

DividerItemDecoration is used to add interior dividers to a RecyclerView using a LinearLayoutManager.

Its constructor takes in your preferred divider as a Drawable.

Drawable dividerDrawable = ContextCompat.getDrawable(this, R.drawable.divider_sample);
  recyclerView.addItemDecoration(new DividerItemDecoration(dividerDrawable));

####StartOffsetItemDecoration

StartOffsetItemDecoration is used to add an offset to the start of a RecyclerView using a LinearLayoutManager. If the RecyclerView is oriented vertically, the offset will be added to the top of the RecyclerView. If the RecyclerView is oriented horizontally, the offset will be added to the lefthand side of the RecyclerView.

Its constructor takes in your preferred offset in pixels.

int offsetPx = 10;  recyclerView.addItemDecoration(new StartOffsetItemDecoration(offsetPx));

####EndOffsetItemDecoration

EndOffsetItemDecoration is used to add an offset to the end of a RecyclerView using a LinearLayoutManager. If the RecyclerView is oriented vertically, the offset will be added to the bottom of the RecyclerView. If the RecyclerView is oriented horizontally, the offset will be added to the righthand side of the RecyclerView.

Its constructor takes in your preferred offset in pixels.

int offsetPx = 10;  recyclerView.addItemDecoration(new EndOffsetItemDecoration(offsetPx));

####GridDividerItemDecoration

GridDividerItemDecoration is used to add interior dividers to a RecyclerView using a GridLayoutManager.

Its constructor takes in your preferred horizontal and vertical dividers, along with the number of columns in the grid.

Drawable horizontalDividerDrawable = ContextCompat.getDrawable(this, R.drawable.divider_horizontal);
 Drawable verticalDividerDrawable = ContextCompat.getDrawable(this, R.drawable.divider_vertical);
 int numColumns = 2;  recyclerView.addItemDecoration(new GridDividerItemDecoration(horizontalDividerDrawable, verticalDividerDrawable, numColumns));

####GridTopOffsetItemDecoration

GridTopOffsetItemDecoration is used to add an offset to the top of a RecyclerView using a GridLayoutManager.

Its constructor takes in your preferred offset in pixels and the number of columns in the grid.

int offsetPx = 10; int numColumns = 2;  recyclerView.addItemDecoration(new GridTopOffsetItemDecoration(offsetPx, numColumns));

####GridBottomOffsetItemDecoration

GridBottomOffsetItemDecoration is used to add an offset to the bottom of a RecyclerView using a GridLayoutManager.

Its constructor takes in your preferred offset in pixels and the number of columns in the grid.

int offsetPx = 10; int numColumns = 2;  recyclerView.addItemDecoration(new GridBottomOffsetItemDecoration(offsetPx, numColumns));

###Project Setup

Current development can be found at the following snapshot:

compile 'com.bignerdranch.android:simple-item-decoration:1.0.0-SNAPSHOT'

Make sure to add Sonatype's snapshots to your repositories closure in the root build.gradle:

allprojects {

  repositories {

maven {
 url "https://oss.sonatype.org/content/repositories/snapshots" 
}

  
}
 
}

You can also clone the project and add it as a module to your project.

###Contribute

Improvements/additions are encouraged. Clone the project with:

git clone https://github.com/bignerdranch/simple-item-decoration.git 

###License

The MIT License  Copyright (c) 2015 Big Nerd Ranch  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 

Resources

An eventbus library for android, simplifies communication between Activities, Fragments, Threads, Services, etc.

A simple implementation of pull-to-refresh ListView.

Generates Retrofit interfaces and related models from Google Cloud Endpoint (GCE) discovery files.

Ready-to-use view pagers for your project.

YouTubeHelper allows to fetch information from YouTube. You can get info about videos, users, comments, etc.

Android library with some Widgets and handy pieces of code I have developed.

Library contains:

  • Horizontal list.
  • Horizontal list with support for item removal.
  • Horizontal list with endless repeating of items.
  • CoverFlow widget derived from endless horizontal list.
  • ContentBand widget which allows for specify finer positioning of views inside scroll-able band using coordinates

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