@Override
public boolean onGenericMotionEvent(MotionEvent event) {
//The input source is a pointing device associated with a display.
//输入源为可显示的指针设备,如:mouse pointing device(鼠标指针),stylus pointing device(尖笔设备)
if (0 != (event.getSource() & InputDevice.SOURCE_CLASS_POINTER)) {
switch (event.getAction()) {
// process the scroll wheel movement...处理滚轮事件
case MotionEvent.ACTION_SCROLL:
//获得垂直坐标上的滚动方向,也就是滚轮向下滚
if (event.getAxisValue(MotionEvent.AXIS_VSCROLL) < 0.0f) {
LogUtils.d("fortest::onGenericMotionEvent down");
}
//获得垂直坐标上的滚动方向,也就是滚轮向上滚
else {
LogUtils.i("fortest::onGenericMotionEvent up");
}
return true;
}
}
return super.onGenericMotionEvent(event);
}
android鼠标滚轮事件监听方法
王的备忘录2023-10-26 13:03
相关推荐
雷一言说6 分钟前
Spring AI 2.0:RAG 文档分块大小策略选择XIAEE7 分钟前
Java 世界历险记:从一行 System.out.println 到整个 Spring 宇宙XIAEE9 分钟前
微前端狂想曲:我试图让三个不同门派的前端住进同一栋楼XIAEE9 分钟前
Linux 生存指南:从"终端恐惧症"到"命令行老司机"XIAEE10 分钟前
实战教程:手机端死活调不出摄像头?聊聊安全上下文(Secure Context)程序员清风10 分钟前
堆与优先队列:从 Top K 到任务调度方舟小孩13 分钟前
开源办公软件海豹办公 1.9.15 实战 从模板异常到 Android WebView 资源回归XIAEE16 分钟前
ES6 与 Node.js 群侠传:那些年我们追过的语法,和那些年把我们追杀的 APIXIAEE16 分钟前
WebRTC 探险记:我是如何让两个浏览器"看对眼"的XIAEE21 分钟前
UniApp 本地打包通关记:Android 是地狱难度,iOS 是隐藏 BOSS