Friday, 24 May 2019

Is there a way to make RecyclerView requiresFadingEdge unaffected by paddingTop and paddingBottom

Currently, I need to use paddingTop and paddingBottom of RecyclerView, as I want to avoid complex space calculation, in my first RecyclerView item and last item.

However, I notice that, requiresFadingEdge effect will be affected as well.

This is my XML

<androidx.recyclerview.widget.RecyclerView
    android:requiresFadingEdge="vertical"
    android:paddingTop="0dp"
    android:paddingBottom="0dp"

    android:overScrollMode="always"
    android:background="?attr/recyclerViewBackground"
    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipToPadding="false" />


When paddingTop and paddingBottom is 40dp

enter image description here

As you can see, the fading effect shift down by 40dp, which is not what I want.


When paddingTop and paddingBottom is 0dp

enter image description here

Fading effect looks fine. But, I need to have non-zero paddingTop and paddingBottom, for my RecyclerView.


Is there a way to make RecyclerView's requiresFadingEdge unaffected by paddingTop and paddingBottom?



from Is there a way to make RecyclerView requiresFadingEdge unaffected by paddingTop and paddingBottom

No comments:

Post a Comment