I'm working on a RecyclerView that shows in horizontal orientation a list of items.
Every item is a CardView with elevation=8dp
. The elevation gives the items a shadow that gets cut by the RecyclerView. So to make it work I added android:clipChildren="false"
and android:clipToPadding="false"
so that the shadow is no longer clipped.
Everything works fine up until the alpha of the RV changes.
The animation I use to hide RV:
view.apply {
animate().alpha(0f)
.setDuration(300)
.withEndAction { view.visibility = outVisibility }
.start()
}
...and the one to show it:
view.apply {
if (visibility != View.VISIBLE) alpha = 0f
animate().alpha(1f)
.setDuration(300)
.withStartAction { view.visibility = View.VISIBLE }
.start()
}
ISSUE
As long as the alpha
of RV is lower than 1.0
the items inside of the RV are being clipped(the shadows). As soon as the alpha
reaches 1.0
the shadows suddenly stop being clipped and everything looks nice again.
Is there anything I can do to fix it?
Same issue occurs if I set the alpha
to a fixed value below 1.0
in XML(not animating at all in this case).
Also the same issue occurs when I try to animate alpha
of items inside the RV.
When RV alpha = 1.0
https://www.dropbox.com/s/g1cun1jqv0op0qw/Screenshot_20190423-180952__01.jpg?dl=0
When RV alpha = 0.9
https://www.dropbox.com/s/s06f9f3orci135m/Screenshot_20190423-180819__01.jpg?dl=0
UPDATE 1
When I try to animate alpha
RV parent instead of RV itself then the issue disappears. But it feels kinda hacky to have to wrap RV in extra parent just to animate its alpha :/