Last active
December 2, 2019 19:25
-
-
Save nikhilpanju/8f4e6581afa44f0d8076d007ba0ebb5c to your computer and use it in GitHub Desktop.
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
class NoScrollRecyclerView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) | |
: RecyclerView(context, attrs, defStyleAttr) { | |
override fun scrollBy(x: Int, y: Int) { | |
val lm = layoutManager as? NoScrollHorizontalLayoutManager | |
lm?.canScrollHorizontally = true | |
super.scrollBy(x, y) | |
lm?.canScrollHorizontally = false | |
} | |
} | |
class NoScrollHorizontalLayoutManager(context: Context) | |
: LinearLayoutManager(context, RecyclerView.HORIZONTAL, false) { | |
var canScrollHorizontally = false | |
override fun canScrollHorizontally(): Boolean = canScrollHorizontally | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment