简体   繁体   中英

How to animate gradient colors in Android like Facebook Shimmer effect

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM