Skip to content

Instantly share code, notes, and snippets.

@chrisbanes
Created October 8, 2019 00:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisbanes/461473cf3e86c73dbca7bbc62915ed49 to your computer and use it in GitHub Desktop.
Save chrisbanes/461473cf3e86c73dbca7bbc62915ed49 to your computer and use it in GitHub Desktop.
gesture_conflict_example_excerpt
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