Wear 上的旋转输入
某些 Wear OS 设备支持旋转输入,如侧面旋钮 (RSB)。当用户旋转旋钮时,应用的当前视图应向上或向下滚动。
如果您在应用中使用 ScrollView、ListView、HorizontalScrollView 或 WearableRecyclerView,那么您的应用视图将默认支持旋转输入。如果您使用上述视图以外的自定义视图,或者您想手动处理旋转输入事件,请参阅添加自定义旋转输入滚动。
请参阅以下相关资源:
焦点最佳做法
为响应旋转输入事件,您的滚动视图必须获得焦点。大多数情况下,滚动视图会自动获得焦点。在您创建 Activity 后,您的滚动视图会立即获得焦点。但是,在某些情况下,您需要手动处理应用视图的焦点,例如:
- 如果您的可滚动视图附加在 Activity.onCreate() 之后(例如,如果您在构建界面之前等待网络请求完成),您必须在附加该视图之后调用 requestFocus。
- 如果您的可滚动视图最初为 INVISIBLE 或 GONE,在将其设置为 VISIBLE 时必须调用
requestFocus
。 - 如果您的 Activity 包含多个可滚动视图(例如,如果您使用的是嵌套滚动),您需要从中选择一个要获得焦点的视图(通常通过 <requestFocus /> 标记进行设置)。RSB 滚动目前不支持嵌套滚动。
- 如果您的界面包含其他某种在用户与它交互时会窃取焦点的视图(这种情况很少见;最常见的示例为
InputText
),则您需要为用户提供某种方式,让他们能够在可滚动视图失去焦点后使其重新获得焦点。这通常可通过侦听可滚动视图上的点按操作并在响应中调用requestFocus
实现。
添加自定义旋转输入滚动
如果您的可滚动视图本身不支持旋转输入滚动,或者您想要执行一些不同于滚动的操作以响应旋转输入事件(例如放大/缩小、旋转表盘等),您可以使用穿戴式设备支持库中的 RotaryEncoder
方法。
以下代码段说明了如何使用 RotaryEncoder
在应用视图中添加自定义滚动:
myView.setOnGenericMotionListener(View.OnGenericMotionListener { v, ev ->
if (ev.action == MotionEvent.ACTION_SCROLL && RotaryEncoder.isFromRotaryEncoder(ev)) {
// Don't forget the negation here
val delta = -RotaryEncoder.getRotaryAxisValue(ev) *
RotaryEncoder.getScaledScrollFactor(context)
// Swap these axes if you want to do horizontal scrolling instead
v.scrollBy(0, Math.round(delta))
return@OnGenericMotionListener true
}
false
})
在模拟器上测试旋转输入按钮
您可以使用 Android 模拟器模拟 Wear 设备上的旋转输入滚动。您可以在运行项目时在模拟器上启动 Wear 应用,也可以将 APK 文件拖动到模拟器上以安装 APK。
如需在模拟器上测试旋转输入,请执行以下操作:
在 SDK 管理器中,使用 SDK 工具标签获取 Android 模拟器 26.0.3 或更高版本。
-
使用 API 25 创建一个 AVD(Android 虚拟设备)。
在 Studio 中,依次选择 Tools > Android > AVD Manager。使用 API 25 创建一个新的 Wear 设备。
-
尝试执行旋转输入滚动。
点击溢出按钮(模拟器工具栏底部的三个点)。点击新窗口中的 Rotary input 标签页以打开旋转输入界面。
以下视频展示了模拟器中的旋转输入。
焦点行为提示
- 从 Android 9(API 级别 28)开始,视图不再隐式获得焦点,而是必须显式获得焦点。
- 应使用
android:focusable="true"
和android:focusableInTouchMode="true"
将可滚动视图注册为可聚焦。 - 默认情况下,启动 Activity 甚至点按某个视图不会使其聚焦(即使该视图可聚焦)。为了实现此行为,视图必须使用
<requestFocus />
标记或手动调用View.requestFocus()
。 - 系统只会将旋转输入事件发送到聚焦的视图。这些事件不会在视图层次结构中向上传递。当且仅当没有聚焦的视图或聚焦的视图从
View.onGenericMotionEvent
返回false
时,系统才会将事件发送到Activity.onGenericMotionEvent
。
第一坑
2021-05-25 10:09:44.860 31038-31038/com.newolf.watchinput E/MessageQueue-JNI: java.lang.IllegalStateException: Could not find wearable shared library classes. Please add <uses-library android:name="com.google.android.wearable" android:required="false" /> to the application manifest
at android.support.wearable.internal.SharedLibraryVersion.verifySharedLibraryPresent(SharedLibraryVersion.java:39)
at android.support.wearable.internal.SharedLibraryVersion.version(SharedLibraryVersion.java:25)
at android.support.wearable.input.RotaryEncoder.isLibAvailable(RotaryEncoder.java:53)
at android.support.wearable.input.RotaryEncoder.isFromRotaryEncoder(RotaryEncoder.java:68)
at com.newolf.watchinput.MainActivity$initListener$3.onGenericMotion(MainActivity.kt:75)
at android.view.View.dispatchGenericMotionEventInternal(View.java:13798)
at android.view.View.dispatchGenericMotionEvent(View.java:13783)
at android.widget.ScrollView.dispatchGenericMotionEvent(ScrollView.java:2280)
at android.view.ViewGroup.dispatchGenericFocusedEvent(ViewGroup.java:2669)
at android.view.View.dispatchGenericMotionEvent(View.java:13779)
at android.view.ViewGroup.dispatchGenericFocusedEvent(ViewGroup.java:2669)
at android.view.View.dispatchGenericMotionEvent(View.java:13779)
at android.view.ViewGroup.dispatchGenericFocusedEvent(ViewGroup.java:2669)
at android.view.View.dispatchGenericMotionEvent(View.java:13779)
at com.android.internal.policy.DecorView.superDispatchGenericMotionEvent(DecorView.java:723)
at com.android.internal.policy.PhoneWindow.superDispatchGenericMotionEvent(PhoneWindow.java:2041)
at android.app.Activity.dispatchGenericMotionEvent(Activity.java:4183)
at com.android.internal.policy.DecorView.dispatchGenericMotionEvent(DecorView.java:682)
at android.view.ViewRootImpl$ViewPostImeInputStage.processGenericMotionEvent(ViewRootImpl.java:6318)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:6050)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5462)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5515)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5481)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5639)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5489)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5696)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5462)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5515)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5481)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5489)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5462)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:8519)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:8439)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:8392)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:8764)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:239)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:363)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:8453)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1088)
java.lang.IllegalStateException: Could not find wearable shared library classes. Please add <uses-library android:name="com.google.android.wearable" android:required="false" /> to the application manifest
然而,在manifest中是有配置的,如下:
<uses-library
android:name="com.google.android.wearable"
android:required="false" />
结论:
也就是说,华为的Watch中是没有com.google.android.wearable
这个library的。
第二坑
修改代码如下:
val scrollView = findViewById<ScrollView>(R.id.scrollView)
scrollView.requestFocus()
scrollView.setOnGenericMotionListener(View.OnGenericMotionListener { v, ev ->
Log.e(TAG, "initListener: ev = $ev" )
if (ev.action == MotionEvent.ACTION_SCROLL ) {
// Don't forget the negation here
val delta = 0.toDouble()
// Swap these axes if you want to do horizontal scrolling instead
Log.e(TAG, "initListener: delta = $delta" )
v.scrollBy(0, Math.round(delta).toInt())
return@OnGenericMotionListener true
}
false
})
打印内容如下:
2021-05-25 10:16:04.548 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832196, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:04.557 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832214, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:04.641 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832297, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:04.661 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832318, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:04.678 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832335, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:04.693 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832350, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:04.713 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832370, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:04.734 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832389, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:04.758 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832413, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:04.779 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832434, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:04.799 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832454, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:04.816 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832470, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:04.835 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832486, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:04.847 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832501, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:04.861 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832517, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:04.879 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832534, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:04.897 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832553, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:04.918 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832573, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:04.940 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832594, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.117 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832772, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.134 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832789, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.150 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70832806, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.467 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833122, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.483 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833141, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.500 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833156, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.515 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833172, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.531 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833188, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.547 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833205, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.563 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833220, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.588 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833245, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.603 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833261, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.619 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833276, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.635 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833292, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.657 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833314, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.693 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833351, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.709 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833367, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.723 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833380, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.739 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833396, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.755 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833413, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.770 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833428, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.787 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833444, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.805 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833461, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.822 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833477, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.836 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833492, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.857 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833513, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.877 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833532, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.898 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833553, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.914 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833569, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.929 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833584, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.946 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833602, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
2021-05-25 10:16:05.961 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833616, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
WTF!!!
2021-05-25 10:16:06.283 31328-31328/com.newolf.watchinput E/MainActivity: initListener: ev = MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=70833940, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
可以看到,除了事件的action是对的,其它的x值和y值都是0,这还怎么玩???
结论:
华为Watch对Google 的API进行很多的改动,目前暂时无法适配Watch的旋转按钮事件让列表滑动起来。