Last active
May 3, 2020 10:46
-
-
Save momvart/281f0e84f31c8288fb224c7d003b9985 to your computer and use it in GitHub Desktop.
A simple extension of GridLayoutManager which makes it possible to lock/disable/set the read-only scroll properties for your recyclerview
This file contains 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
import android.content.Context | |
import androidx.recyclerview.widget.GridLayoutManager | |
class ScrollLockableGridLayoutManager(context: Context, spansCount: Int) : GridLayoutManager(context, spansCount) { | |
var canScrollVertically = true | |
override fun canScrollVertically(): Boolean = | |
if (!canScrollVertically) false | |
else super.canScrollVertically() | |
var canScrollHorizontally = true | |
override fun canScrollHorizontally(): Boolean = | |
if (!canScrollHorizontally) false | |
else super.canScrollHorizontally() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment