I want to prevent a button from intercepting 2 finger taps. I have a standard Android Activity with onTouchEvent
and a standard button which occupies more or less the entire screen.
private const val DEBUG_TAG = "Gestures"
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val button = this.findViewById<Button>(R.id.button2)
button.setOnClickListener { Log.d(DEBUG_TAG, "Button tapped")
}
}
override fun onTouchEvent(event: MotionEvent): Boolean {
Log.d(DEBUG_TAG, "onTouchEvent")
val action: Int = MotionEventCompat.getActionMasked(event)
val pointerCount = event.pointerCount;
if (pointerCount > 1) {
Log.d(DEBUG_TAG, "Multi-touch")
}
return super.onTouchEvent(event)
}
}
I want the button to intercept 1 finger taps but ignore 2 finger taps and propagate them to the onTouchEvent
of the activity. Currently it intercepts even 2 finger taps.
I tried this in styles.xml
but no luck.
<item name="android:windowEnableSplitTouch">false</item>
<item name="android:splitMotionEvents">false</item>
Ideally I would like to do that app-wide but still having onTouchEvent
being able to detect 2 finger taps.