@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
相关推荐
Coffeeee19 小时前
如何使用Glide和Coil加载WebP动图SimonKing19 小时前
艹,维护AI写的代码,我心态崩了......用户2986985301419 小时前
Java Word 文档样式进阶:段落与文本背景色设置完全指南Kapaseker19 小时前
5 分钟搞懂 Kotlin DSL恋猫de小郭20 小时前
AI Agent 开发究竟是啥?如何用 AI 开发 Agent ?深入浅出给你一套概念黄林晴20 小时前
Android 17 正式发布!target 37 一大批旧代码直接不能用了Carson带你学Android20 小时前
Android 17 正式发布:AI 终于成了系统能力三少爷的鞋21 小时前
当 UseCase 开始长期监听,它可能已经不是 UseCase 了恋猫de小郭1 天前
Android 限制侧载新进展,谷歌联合国内厂商推验证计划恋猫de小郭1 天前
解读 Android 17 全新内存限制,有没有“豁免”后门?