-
-
Save chrisbanes/461473cf3e86c73dbca7bbc62915ed49 to your computer and use it in GitHub Desktop.
gesture_conflict_example_excerpt
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
private val gestureExclusionRects = mutableListOf<Rect>() | |
private fun updateGestureExclusion() { | |
// Skip this call if we're not running on Android 10+ | |
if (Build.VERSION.SDK_INT < 29) return | |
// First, lets clear out any existing rectangles | |
gestureExclusionRects.clear() | |
// Now lets work out which areas should be excluded. For a SeekBar this will | |
// be the bounds of the thumb drawable. | |
thumb?.also { t -> | |
gestureExclusionRects += t.copyBounds() | |
} | |
// If we had other elements in this view near the edges, we could exclude them | |
// here too, by adding their bounds to the list | |
// Finally pass our updated list of rectangles to the system | |
systemGestureExclusionRects = gestureExclusionRects | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment