[MaterialButtonGroup] Long press gesture detectors on children may not work (depending on position)
ATTENTION: This library is now in maintenance mode. See https://github.com/material-components/material-components-android#readme.
Only critical issues will be addressed.
Description: Long press gesture detector on a button in MaterialButtonGroup often fails (depending on its position).
Expected behavior: Gesture should be reliably detected.
Android API version: 17
Material Library version: 1.14.0
Device: Pixel
This is more for posterity than anything else, as I assume it won't be fixed. I have a MaterialButtonGroup with 3 MaterialButton children. Buttons at index 0 and 2 have a GestureDetector to detect a long press. Index 1 has weight 0, the others have weight 1.
The button at index 0 reliably detects the gesture, but button at index 2 doesn't. If moved from index 2 to 1, it works. This is because the button shape change that happens when it is pressed moves the MotionEvent location, such that it sometimes (not always) falls out of the detector's slop rectangle.
Other than disabling the button shape change (setting app:buttonSizeChange to @null) I haven't found a way around it.
Source: material-components/material-components-android