I'm a beginner in Android development and I'm developing an app for little kids. As you know kids tend to hold the screen with one hand (where it touchs the screen already) and click the screen with another hand. Unfortunately, this renders the screen unresponsive to the clicks. My question is, is there a way to make the screen respond to a click even if it is already touched with one finger?
There is, by handling in your onTouchEvent()
the MotionEvent
ACTION_POINTER_DOWN
. Imagine you want to show a Toast
when more than one finger is touching the screen; you could do it like this:
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) {
Toast.makeText(this, "More than one finger on screen", Toast.LENGTH_SHORT);
}
}
You can check the multi-touch Android developer's page for more info on the subject.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.