@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
相关推荐
2601_963869952 小时前
【计算机毕业设计】基于 Spring Boot+Vue的手工体验馆管理系统的设计与实现曹牧2 小时前
Java:BeanListHandler白鸽(二般)8 小时前
MinIO Java Client API软萌萌的19 小时前
Java Spring Boot 修改yml配置&加载顺序规则IT小盘10 小时前
13-企业Prompt模板-角色任务约束与输出格式爱敲键盘的猴子10 小时前
Java并发编程 -- volatileplainGeekDev12 小时前
工厂模式 → Hilt雨白12 小时前
深入理解 Kotlin 协程 (十):引而不发,探秘 Flow 冷流机制与异常透明性plainGeekDev12 小时前
Application 单例 → Hilt Singleton888CC++12 小时前
C语言与C++的区别:从面向过程到面向对象