Closed CHRehan closed 6 years ago
@CHRehan I would say it's not a bug, but a feature. Basically, we have a shader which contains the Lineargradient
(shimmer line) and a bitmap which contains the bounds of everything which is not transparent. And in every frame, we blend these 2 together. Since your ShimmerLayout has a background color, when we blend it together with the Lineargradient
you can see the whole shimmer line as we don't have to cut out parts to match what is not transparent.
The solution for this is to embed ShimmerLayout
in another ViewGroup
which contains the background color. Or a better one to use ConstraintLayout
as a parent, so you can easily position a simple View behind ShimmerLayout
with a background color. In this way, you avoid nesting Views.
@veghtomi Howto use it when ConstraintLayout as a parent and 4 child card views = https://gist.github.com/LOG-TAG/dc13db135724d9738c8664e432c85cb5
inside that cardview gain ConstraintLayout with widgets texviews? just after declaring the parent put the ShimmerLayout and close before parent closes?
@LOG-TAG The easiest way if you want to animate only the contents of the CardView is the following. Add a ShimmerLayout as a child of the CardView, and after add the contents (ConstraintLayout) as the child of ShimmerLayout. The ConstraintLayout and ShimmerLayout should have a transparent background, so the animation will only appear on the Views and TextViews. If you want to modify the background, add one to the CardView, so it will not interfere with the animation.
Just write me if you have more questions!
When i add background color animation ripple collapsed with other Views