Issue
I have a RecyclervView
with a rounded Drawable
background and .clipToOutline = true
in order to keep the overscroll animation inside the background. When I set requiresFadingEdge="vertical"
, there's a glitch where the fading edge is; example below. How can I fix this? The issue doesn't appear when I set .clipToOutline = false
or when I don't have a fading edge, but I would like both of these effects. Thanks for the help.
You can see the issue in the bottom corners of the blue RecyclerView
.
Solution
This can be fixed by setting a different layer type either in xml, or programatically when initialising your recyclerview:
XML
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layerType="hardware"
...
Programatically
recyclerView.setLayerType(VIEW.LAYER_TYPE_HARDWARE, null)
You can also use LAYER_TYPE_SOFTWARE
, but it's better to use LAYER_TYPE_HARDWARE
for performance reasons.
Find out more about this 2 options in these docs:
- https://developer.android.com/reference/android/view/View#LAYER_TYPE_HARDWARE
- https://developer.android.com/reference/android/view/View#LAYER_TYPE_SOFTWARE
Answered By - pina14
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.