小米手机 特殊bug touch事件 弹出popupwindow时 ,不执行 ACTION_UP,执行ACTION_CANCEL

                case MotionEvent.ACTION_DOWN: {
    
    
                   
                    lastX = event.getX();
                    lastY = event.getY();
                }
                case MotionEvent.ACTION_MOVE: {
    
    
                   
                    lastX = event.getX();
                    lastY = event.getY();
                }

                // 为了兼容小米手机,弹出popup时,小米不调用ACTION_UP,调用ACTION_CANCEL,而且 event.getX 变成相对屏幕的
                case MotionEvent.ACTION_CANCEL:
                case MotionEvent.ACTION_POINTER_UP:
                case MotionEvent.ACTION_UP: {
    
    
                    float xValue = event.getX();
                    float yValue = event.getY();
                    if (event.getAction() == MotionEvent.ACTION_CANCEL) {
    
    
                        xValue = lastX;
                        yValue = lastY;
                    }

猜你喜欢

转载自blog.csdn.net/kejia90/article/details/112337624