Content placeholder animation like Facebook Tutorial using Kotlin

(216 Views)

While loading data from API, instead of using the usual loaders, we can make the loading screen
more interesting using Facebook's Shimmer library.We can also do this shimmer effect in our Android App using
Shimmer library by Facebook.This library adds Shimmer effect on to any custom view that we define. This can be implemented in the following way:

Include the following in app-level gradle file(build.gradle)

implementation 'com.facebook.shimmer:shimmer:0.1.0'

First we have to design placeholder layout that is similar to RecyclerView's adapter layout.

placeholder.xml

Include that placeholder layout to the ShimmerLayout.

Design adapter layout for RecyclerView.

ShimmerActivity.kt

To start animation, startShimmerAnimation() can be used and for stoping it, stopShimmerAnimation() can be used.Please find below the code: