How to fix RecyclerView requiresFadingEdge and clipToOutline glitch

Solution 1:

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