[英]MIUI10 android textview setOnTouchListener ACTION_UP not called
I am confused about this strange problem. 我对这个奇怪的问题感到困惑。 Normally, on many phones, this is not a problem. 通常,在许多电话上,这不是问题。 But I tried three MIUI10 phones with this problem, and other systems have not encountered it. 但是我尝试了三台MIUI10手机来解决此问题,而其他系统则没有遇到。 Perhaps this is a MIUI10 system bug? 也许这是MIUI10系统错误?
If you have a MIUI10 phone, please help test it. 如果您有MIUI10手机,请帮助进行测试。
And how can I solve this problem to be compatible with many devices? 以及如何解决此问题以使其与许多设备兼容? All help is welcome. 欢迎所有帮助。
The code is as follows, very simple: 代码如下,非常简单:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="50dp"
android:padding="15dp"
android:background="#1ad9ca"
android:textColor="#ffffff"
android:text="Hold to talk" />
</RelativeLayout>
findViewById(R.id.text).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
Log.d(TAG, "ACTION_DOWN");
break;
case MotionEvent.ACTION_MOVE:
Log.d(TAG, "ACTION_MOVE");
break;
case MotionEvent.ACTION_UP:
Log.d(TAG, "ACTION_UP");
break;
case MotionEvent.ACTION_CANCEL:
Log.d(TAG, "ACTION_CANCEL");
break;
}
return true;
}
});
And in my device, Hold TextView for a few seconds and raise my hand , ACTION_CANCEL is called, and ACTION_UP is not called . 在我的设备中, 按住TextView几秒钟并举起我的手 ,将调用ACTION_CANCEL, 而未调用ACTION_UP 。 Here are the logs: 以下是日志:
D/MainActivity: ACTION_DOWN
D/MainActivity: ACTION_MOVE
D/MainActivity: ACTION_MOVE
D/MainActivity: ACTION_CANCEL
And I want to do some logic in ACTION_UP case , not in ACTION_CANCEL case. 我想在ACTION_UP的情况下 ,而不是在ACTION_CANCEL的情况下 , 做一些逻辑 。
The test device info: 测试设备信息:
Phone name: Xiaomi 8
Android system version: Android 9
MIUI system version: MIUI 10.1.2.0
Verified on my miui phone, this problem occurs only on 10.2.xx version, when upgrading to 10.3.3.0, the problem no more occurs. 在我的miui手机上进行了验证,仅在10.2.xx版本上会出现此问题,升级到10.3.3.0时,不会再出现此问题。
While dispatching ACTION_UP event, miui intercepts this event and changes action from ACTION_UP to ACTION_CANCEL, but nothing popup shows on screen, seems like a bug on 10.2.xx 在分派ACTION_UP事件时,miui会拦截此事件并将动作从ACTION_UP更改为ACTION_CANCEL,但屏幕上没有任何弹出窗口,似乎是10.2.xx上的错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.