How to allow single multitouch

折月煮酒 提交于 2019-12-08 11:33:23

问题


I am writing an custom ViewGroup where I need to use only single finger touch and wanted to remove multitouch completely. I have checked with other option android:splitMotionEvents="false" android:windowEnableSplitTouch="false" but both are not working.

EDIT

@Override
    public boolean onTouchEvent(MotionEvent ev) {

        DragHelper.processTouchEvent(ev);

        return true;
    }

Any suggestion !


回答1:


Try following code in your custom view.

@Override
public boolean onTouchEvent(MotionEvent event) 
{
    // TODO Auto-generated method stub
    if(event.getPointerCount() > 1) {
        System.out.println("Multitouch detected!");
        return true;
    }
    else
    {
        return super.onTouchEvent(event);
    }
}


来源:https://stackoverflow.com/questions/29072698/how-to-allow-single-multitouch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!