How to animate gradient colors in Android like Facebook Shimmer effect

1.4k views Asked by At

I am trying to add a loading placeholder (just a linear layout) until I get a response from the API. I want to add a Shimmer like effect to the placeholder without using an external library.

I tried using a GradientDrawable with a ValueAnimator from here but it is not working. I also tried adding the second View with a specific color and animate this view over the placeholder view.

I want to know how to do it without using an external library, or adding a second view.

1

There are 1 answers

1
ashakirov On

you can check "facebook shimmer" library sources, it's pretty simple, there are only 3 class in that library (custom view + custom drawable).
https://github.com/facebook/shimmer-android/tree/master/shimmer/src/main/java/com/facebook/shimmer