Created
July 11, 2018 06:09
-
-
Save JulienArzul/5700ce1072a7ea972e26b13691a56e68 to your computer and use it in GitHub Desktop.
RecyclerView class that supports drawing fading edges with clipToPadding=false
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.julienarzul.android.recyclerview | |
import android.content.Context | |
import android.support.v7.widget.RecyclerView | |
import android.util.AttributeSet | |
class FadingEdgeRecyclerView : RecyclerView { | |
constructor(context: Context) : super(context) | |
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) | |
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) | |
override fun isPaddingOffsetRequired(): Boolean { | |
return !clipToPadding | |
} | |
override fun getLeftPaddingOffset(): Int { | |
return if (clipToPadding) 0 else -paddingLeft | |
} | |
override fun getTopPaddingOffset(): Int { | |
return if (clipToPadding) 0 else -paddingTop | |
} | |
override fun getRightPaddingOffset(): Int { | |
return if (clipToPadding) 0 else paddingRight | |
} | |
override fun getBottomPaddingOffset(): Int { | |
return if (clipToPadding) 0 else paddingBottom | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks bro