ShimmerRecyclerView


Source link: https://github.com/sharish/ShimmerRecyclerView

ShimmerRecyclerView

Intro

A custom recycler view with shimmer views to indicate that views are loading. The recycler view has a built-in adapter to control the shimmer appearance and provide two methods -

  • showShimmerAdapter() - set up a demo adapter a predefined number of child demo views.
  • hideShimmerAdapter() - restores your adapter to show the actual child elements.

Demo Screen

There are two kinds of shimmer animation which you can see here:

  1. This type of shimmer effect uses the whole ViewHolder item to animate on.
List Demo Grid Demo
  1. Here the shimmer effect only applied on for those views which background color is nontransparent.
List Demo Grid Demo

Shimmer effect types

  1. As you can see the first demo examples show that the whole ViewHolder item is animated. To achieve the desired effect, the children of the ShimmerLayout should have a nontransparent background.

  2. You can achieve the second kind of shimmer effect by adding only one ViewGroup child to the ShimmerLayout with a transparent background. This ViewGroup will have the other views with nontransparent backgrounds on which the effect will be seen.

    You may wonder how can you add background to the root view of the ViewHolder, if you do not have direct access to the ShimmerLayout and the only child has a nontransparent background. The solution for this is to use the shimmer_demo_view_holder_item_background attribute.

Attributes and Methods

Following are the attributes and methods to initialise the demo views.

XML Attributes Java Methods Explanation
app:shimmer_demo_child_count setDemoChildCount(int) Integer value that sets the number of demo views should be present in shimmer adapter.
app:shimmer_demo_layout setDemoLayoutReference(int) Layout reference to your demo view. Define your my_demo_view.xml and refer the layout reference here.
app:shimmer_demo_layout_manager_type setDemoLayoutManager(LayoutManagerType) Layout manager of demo view. Can be one among linear_vertical or linear_horizontal or grid.
app:shimmer_demo_shimmer_color - Color reference or value. It can be used to change the color of the shimmer line.
app:shimmer_demo_angle - Integer value between 0 and 30 which can modify the angle of the shimmer line. The default value is zero.
app:shimmer_demo_view_holder_item_background - Color or an xml drawable for the ViewHolder background if you want to achieve the second type of shimmer effect.

Usage

Define your xml as:

<com.cooltechworks.views.shimmer.ShimmerRecyclerView

xmlns:app="http://schemas.android.com/apk/res-auto"

android:id="@+id/shimmer_recycler_view"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:demo_child_count="10"

app:demo_grid_child_count="2"

app:demo_layout="@layout/layout_demo_grid"

app:demo_layout_manager_type="grid"

app:shimmer_demo_angle="20"

/> 

where @layout/layout_demo_grid refers to your sample layout that should be shown during loading spinner. Now on your activity onCreate, initialize the shimmer as below:

ShimmerRecyclerView shimmerRecycler = (ShimmerRecyclerView) findViewById(R.id.shimmer_recycler_view);
 shimmerRecycler.showShimmerAdapter();

Adding to your project

  • Add the following configuration in your build.gradle file.
repositories {

  jcenter()
  maven {
 url "https://jitpack.io" 
}
 
}
  dependencies {

  compile 'com.github.sharish:ShimmerRecyclerView:v1.1' 
}

Developed By

Used libraries

  • ShimmerLayout: the library which achieves the shimmer effect in a memory efficient way.

License

The repo is released under following licenses

Apache License for ShimmerRecycler
Apache License for ShimmerLayout

Resources

An Android library which can be used for implementing PIN lock mechanism in Android applications.

Android library helps take screenshots for publishing on Google Play Store.

Elastic Progress Bar.

Android's video recording APIs are very difficult to figure out, especially since a lot of manufacturers like to mount their camera sensors upside down or sideways. This library is a result of lots of research and experimentation to get video recording to work universally.

Android Dynamic Loader is a plugin system. The host application is like a browser, but instead of loading web pages, it loads plugins which could be run natively on Android system.

A library to work with RecyclerView as easily as if you'd use ListView or GridView.

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