A custom recycler view with shimmer views to indicate that views are loading.

Overview

Android Arsenal Build Status

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_mask_width setDemoShimmerMaskWidth(float) Float value between 0 and 1 which can modify the width of the shimmer line. The default value is 0.5.
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.
app:shimmer_demo_reverse_animation - Defines whether the animation should be reversed. If it is true, then the animation starts from the right side of the View. Default value is false.

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:shimmer_demo_child_count="10"
        app:shimmer_demo_grid_child_count="2"
        app:shimmer_demo_layout="@layout/layout_demo_grid"
        app:shimmer_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 {
    implementation 'com.github.sharish:ShimmerRecyclerView:v1.3'
}

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

Comments
  • Fatal Exception: java.lang.IllegalArgumentException: width and height must be > 0

    Fatal Exception: java.lang.IllegalArgumentException: width and height must be > 0

    I am getting this error in ShimmerLayout class. What could be the issue?

    Fatal Exception: java.lang.IllegalArgumentException: width and height must be > 0 at android.graphics.Bitmap.createBitmap(Bitmap.java:815) at android.graphics.Bitmap.createBitmap(Bitmap.java:794) at android.graphics.Bitmap.createBitmap(Bitmap.java:761) at io.supercharge.shimmerlayout.ShimmerLayout.startShimmerAnimation(Unknown Source) at io.supercharge.shimmerlayout.ShimmerLayout.getSourceMaskBitmap(Unknown Source) at io.supercharge.shimmerlayout.ShimmerLayout.stopShimmerAnimation(Unknown Source) at io.supercharge.shimmerlayout.ShimmerLayout.startShimmerAnimation(Unknown Source) at io.supercharge.shimmerlayout.ShimmerLayout.dispatchDraw(Unknown Source)

    opened by vaibhav-droid 7
  • Cannot find resource identifier for angle and view holder background

    Cannot find resource identifier for angle and view holder background

    AS 2.3.2 Stable Using version 'v1.0.1'

    This is how I'm defining the ShimmerRecyclerView in the XML

    <com.cooltechworks.views.shimmer.ShimmerRecyclerView
         android:id="@+id/rv_quests"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:orientation="vertical"
         app:layoutManager="LinearLayoutManager"
         app:shimmer_demo_angle="180"
         app:shimmer_demo_child_count="3"
         app:shimmer_demo_layout="@layout/layout_demo"
         app:shimmer_demo_layout_manager_type="linear_vertical"
         app:shimmer_demo_view_holder_item_background="@android:color/white"
         tools:listitem="@layout/item_quest"
     />
    

    This is the output I'm getting when I build the app

    Error:(51) No resource identifier found for attribute 'shimmer_demo_angle' in package 'me.aungkyawpaing.testshimmer'
    Error:(51) No resource identifier found for attribute 'shimmer_demo_view_holder_item_background' in package 'me.aungkyawpaing.testshimmer'
    Error:(51) No resource identifier found for attribute 'shimmer_demo_angle' in package 'me.aungkyawpaing.testshimmer'
    Error:(51) No resource identifier found for attribute 'shimmer_demo_view_holder_item_background' in package 'me.aungkyawpaing.testshimmer'
    

    EDIT: Just checked with the inspector. Seems like it's not getting added to attribute list in R, only four attrs were added which are followings: inspector

    opened by vincent-paing 6
  • Added shimmer mask width

    Added shimmer mask width

    This PR adds the ability to tweak the default value for the shimmer line width.

    Keeps compatibility with the old implementation adding the default to 0.5f that is the same in ShimmerLayout.

    opened by alejandrorosas 5
  • Does this library manipulate the actual itemView for shimmering effect or do I need to create two item views, one for showing actual data and one demo view for shimmering

    Does this library manipulate the actual itemView for shimmering effect or do I need to create two item views, one for showing actual data and one demo view for shimmering

    There are more than 6 recycler views in my project and each of them has its own itemview (that we provide in ViewHolder class). So should I provide these already existing itemViews to the attribute "app:demo_layout" or should I create another shimmering views for this attr? I didn't find any detail regarding this in the docs. Shouldn't library be manipulating the itemView itself to get required view for shimmering effect?

    Also what's the use of ShimmerAdapter, ShimmerLayout and ShimmerViewHolder? From the docs it seems, I don't need to use any of these to create shimmer effect.

    opened by kvipul 5
  • ShimmerRecyclerView always show one item when layout manager equals

    ShimmerRecyclerView always show one item when layout manager equals "linear_horizontal"

    When applying "linear_horizontal" to the recycleview it always shows one 1 item. No matter what value I set to "shimmer_demo_child_count".

    I think the problem is viewholder_shimmer.xml, as it uses match_parent for width showing a single item will occupy the full width and not be able to show the second item for horizontal recyclerview.

    The problem solved when I overrided viewholder_shimmer.xml and set it wrap_content for width.

    opened by kaiyan910 4
  • Kotlinize the Library and the Application Sample

    Kotlinize the Library and the Application Sample

    This PR adds Kotlin powerful features for the library and the sample APP, I did a simple work which is converting your existing code from Java to kotlin, I hope this is a Good PR.

    opened by Younes-Charfaoui 2
  • layoutManager.findLastCompletelyVisibleItemPosition() doesn't work correctly

    layoutManager.findLastCompletelyVisibleItemPosition() doesn't work correctly

    hello. I'm using your library for a project... it works correctly, but when I set a LinearLayout to ShimmerRecyclerView and then I call findLastCompletelyVisibleItemPosition(), it returns incorrect number even negative numbers. Could u help me??? Thanks a lot...

    opened by mohammadms2008 2
  • recyclerView.hideShimmerAdapter() resets the scroll position

    recyclerView.hideShimmerAdapter() resets the scroll position

    When implementing endless RecyclerView scrolling when I call hideShimmerAdapter on the request's callback, it resets the scrolling position.

    I had to implement a workaround in order to call hideShimmerAdapter only once

    if (page == 1 && recyclerView != null) {
        recyclerView.hideShimmerAdapter();
    } 
    

    Is this expected?

    Thanks

    opened by mitsest 2
  • Application tag attributes are duplicate in Manifest of library module

    Application tag attributes are duplicate in Manifest of library module

    While importing this library, I am getting duplicate 'allowBackup' tag. I don't think that application tag is required in the Manifest of the Library module.

    Here is the error: `Error:Execution failed for task ':app:processDebugManifest'.

    Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:32:9-36 is also present at [com.github.sharish:ShimmerRecyclerView:v1.0.1] AndroidManifest.xml:28:9-35 value=(true). Suggestion: add 'tools:replace="android:allowBackup"' to element at AndroidManifest.xml:28:5-32:19 to override.`

    opened by kevalpatel2106 2
  • Cannot Build with Gradle

    Cannot Build with Gradle

    It says Failed to resolve. Tried both compile 'com.github.sharish:ShimmerRecyclerView:v1.0.1'

    and compile 'com.github.sharish:ShimmerRecyclerView:1.0.1' (without 'v' before version)

    both fails please look into it.

    opened by inanmadak 2
  • error unable to build

    error unable to build

    Error:(744) Attribute "shape" already defined with incompatible format. Error:(701) Original attribute defined here. Error:(744) Attribute "shape" already defined with incompatible format. Error:(701) Original attribute defined here. Error:(23, 53) String types not allowed (at 'shape' with value 'linear'). Error:Execution failed for task ':app:processDebugResources'.

    com.android.ide.common.process.ProcessException: Failed to execute aapt

    opened by Midhilaj 2
  • android:orientation=

    android:orientation="horizontal" is invalid

    <ShimmerRecyclerView 
    android:orientation="horizontal" 
    app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
    />
    

    is invalid

    <RecyclerView 
    android:orientation="horizontal" 
    app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
    />
    

    is valid

    opened by TianGuisen 1
  • ShimmerLayout is deprecated

    ShimmerLayout is deprecated

    Hi, the ShimmerLayout used in this library (https://github.com/team-supercharge/ShimmerLayout) is now deprecated, should use https://github.com/facebook/shimmer-android instead

    opened by megaacheyounes 0
  • Shimmer is Not Showing in Some Fragments

    Shimmer is Not Showing in Some Fragments

    Hello Dear, This is really good Library and I am using this in my project. Well I am facing a weired problem I dont know why But I have spent more than 3 hours to figure out this but vain. The thing is shimmer not showing in some fragments

    ` <androidx.coordinatorlayout.widget.CoordinatorLayout android:id="@+id/bgLayout" android:layout_width="match_parent" android:layout_height="match_parent">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:elevation="@dimen/dp0"
        android:paddingBottom="@dimen/dp7"
        android:background="@color/white">
    
    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/white"
        app:contentInsetStartWithNavigation="0dp"
        app:layout_scrollFlags="scroll|enterAlways" />
    
    <EditText
        android:layout_width="match_parent"
        android:layout_height="@dimen/dp50"
        android:drawableStart="@drawable/ic_search"
        android:background="@drawable/search_background"
        android:drawablePadding="@dimen/dp15"
        android:paddingStart="@dimen/dp15"
        android:hint="Search"
        android:layout_marginEnd="@dimen/dp15"
        android:layout_marginStart="@dimen/dp15"
        android:clickable="true"
        android:focusable="false"
        android:layout_marginTop="@dimen/dp7"
        android:fontFamily="@font/nunitosans_regular"/>
    
    </com.google.android.material.appbar.AppBarLayout>
    
    
    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true"
        android:scrollbars="none"
        android:scrollingCache="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/mainDiv"
            android:orientation="vertical"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">
    
    
    
    
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/searchByBodyTypeContainer"
        android:background="@color/white"/>
    
    
            <com.cooltechworks.views.shimmer.ShimmerRecyclerView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/allSearchResultRecyclerView"
                android:paddingBottom="@dimen/dp6"
                android:clipToPadding="false"
                app:shimmer_demo_child_count="10"
                app:shimmer_demo_layout_manager_type="linear_vertical"
                app:shimmer_demo_layout="@layout/shimmer_car_list"
                app:shimmer_demo_shimmer_color="#21ffffff"/>
    
        </LinearLayout>
    </androidx.core.widget.NestedScrollView>
    
    <!--bottom sheet container-->
    <FrameLayout
        android:id="@+id/bottom_sheet"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" />
    

    </androidx.coordinatorlayout.widget.CoordinatorLayout>`

    And shimmer_car_list is here Bellow

    `

    <com.google.android.material.card.MaterialCardView

    android:layout_width="match_parent"
    android:layout_height="@dimen/dp140"
    style="@style/SearchResult"
    android:id="@+id/imageCard"
    app:cardCornerRadius="@dimen/dp8"
    android:layout_margin="@dimen/dp6"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    
    </com.google.android.material.card.MaterialCardView>`
    

    How I am calling it is here bellow

    binding.allSearchResultRecyclerView.showShimmerAdapter();

    Shimmer not showing :(

    opened by kingnightdrifter 1
  • Publishing it somewhere other than Jitpack

    Publishing it somewhere other than Jitpack

    Hi! Lately, Jitpack has been having several downtime issues. Have you considered moving to a different host (e.g. JCenter)?

    Also, even just adding the maven-publish plugin and the relevant integration (see an example here) would already help, and I can help with that

    opened by sergiomarqmoura 0
Releases(v1.3)
Owner
Harish Sridharan
Harish Sridharan
Examples of custom recycler view items. Automatically detecting a dominant color of an image using Picasso and Palette libraries

custom-image-list-item Examples of custom RecyclerView items using Data Binding Features: Loading images urls with the help of a Picasso library Autom

Alina Stepanova 2 Sep 12, 2022
Handy library to integrate pagination, which allow no data layout, refresh layout, recycler view in one view and easy way to bind pagination in app.

Pagination View Handy library to integrate pagination, which allow no data layout, refresh layout, recycler view in one view and easy way to bind pagi

DhiWise 4 Dec 18, 2021
A couple of sticky header decorations for android's recycler view.

DEPRECATION NOTICE This library has not been touched in a very long time and many things have changed in the android ecosystem since then. Updating an

Eduardo Barrenechea 879 Nov 26, 2022
A couple of sticky header decorations for android's recycler view.

DEPRECATION NOTICE This library has not been touched in a very long time and many things have changed in the android ecosystem since then. Updating an

Eduardo Barrenechea 879 Nov 26, 2022
Medium sample for frogo-recycler-view

mediumstory-frogo-recycler-view Tutorial how to use frogo-recycler-view lib Medium sample for frogo-recycler-view Medium Story Here frogo-recycler-vie

Muhammad Faisal Amir 5 Sep 12, 2021
Simple lib to create a endless recycler view scroll

Endless RecyclerView A simple lib to create an infinite list in a RecyclerView. When you reach the end of the list, a callback is triggered, where you

Jaison Klemer 4 Sep 2, 2022
Android Development by using Kotlin, this App uses the concept of API, Recycler Methods and Databases.

Bookstore App by using Kotlin This Project is made using Kotlin, and it uses main concepts of API, Databases, Fragments and many more. This Applicatio

Abeye Tewodros 4 Nov 23, 2022
A RecyclerView(advanced and flexible version of ListView in Android) with refreshing,loading more,animation and many other features.

UltimateRecyclerView Master branch: Dev branch: Project website:https://github.com/cymcsg/UltimateRecyclerView Description UltimateRecyclerView is a R

MarshalChen 7.2k Jan 2, 2023
RetroDialer - Custom view like a retro telephone dialer

RetroDialer Custom view like a retro telephone dialer Demo

Kshitij Kumar 7 Feb 5, 2022
A layout manager for the RecyclerView with interchangeable linear, grid, and staggered displays of views, all with configurable section headers including the sticky variety as specified in the material design docs.

SuperSLiM This is the version 5 development branch. Project Plan Support me on Patreon Blog What is Version 5 Version 5 is the current development bra

Tonic Artos 2.1k Jan 2, 2023
ANDROID. ChipsLayoutManager (SpanLayoutManager, FlowLayoutManager). A custom layout manager for RecyclerView which mimicric TextView span behaviour, flow layouts behaviour with support of amazing recyclerView features

ChipsLayoutManager This is ChipsLayoutManager - custom Recycler View's LayoutManager which moves item to the next line when no space left on the curre

Oleg Beloy 3.2k Dec 25, 2022
Carousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager.

Carousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager.

Jack and phantom 504 Dec 25, 2022
Simple plug and play custom RecyclerView

InfiniteScrollRecyclerView Pros: Simple plug and play custom RecyclerView. Easy to use Built on top of RecyclerView, hence it is performant as it work

Frontier 61 Dec 28, 2022
ItemDecorator - Custom item decorator for adding divider for only the first item of a RecyclerView

ItemDecorator Custom item decorator for adding divider for only the first item o

null 1 Apr 1, 2022
Android library defining adapter classes of RecyclerView to manage multiple view types

RecyclerView-MultipleViewTypeAdapter RecyclerView adapter classes for managing multiple view types Release Note [Release Note] (https://github.com/yqr

Yoshihito Ikeda 414 Nov 21, 2022
Android library for RecyclerView to manage order of items and multiple view types.

recyclerview-binder Android Library for RecyclerView to manage order of items and multiple view types. Features Insert any items to wherever you want

Satoru Fujiwara 185 Nov 15, 2022
Dogglers app uses a RecyclerView in horizontal, vertical and grid view to show a group of CardViews

Welcome to DogglersApp! This app is the final project from Unit 2 of Android Basics in Kotlin given by Google codelabs: https://developer.android.com/

David Ortega Farrerons 1 Feb 25, 2022
A customizable and easy-to-use Timeline View library for Android

TimelineView A customizable and easy-to-use Timeline View library for Android Can be used as a standalone view or as a RecyclerView decorator Setup 1.

Riccardo Lattarulo 189 Dec 10, 2022