@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
相关推荐
私人珍藏库4 小时前
【Android】Soul v5.86.0 内置模块版橙淮5 小时前
并发编程(六)千里马学框架5 小时前
aosp新增窗口层级 Type 完整实现方案(有源码)-wms需求和面试题拽着尾巴的鱼儿5 小时前
springboot openfeign 自定义feign 接口重试机制白露与泡影5 小时前
2026大厂Java面试题大全!牛客网最新版EntyIU6 小时前
JVM内存与GC笔记XS0301066 小时前
并发编程 六yaoxin5211236 小时前
419. 现代 Java IO 最佳实践 - 写入文本文件雪宫街道6 小时前
synchronized 锁的范围:对象锁、类锁与代码块锁x***r1516 小时前
linux安装 jdk-8u291-linux-x64.tar.gz 详细步骤(解压配置环境变量)