Xiaomi mobile phone has a special bug touch event. When the popupwindow pops up, ACTION_UP is not executed, but ACTION_CANCEL is executed.

                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;
                    }

Guess you like

Origin blog.csdn.net/kejia90/article/details/112337624