@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
相关推荐
小马哥程序开发10 分钟前
[点赞收藏免费领取 · 项目源码]57105基于Spring Boot的充电桩管理系统的设计与实现三少爷的鞋19 分钟前
Android 架构指南:suspend 如何响应取消?别再给 Repository 加 `cancel()`九皇叔叔41 分钟前
【09】SpringBoot4 MyBatisPlus 增删改查(CRUD)迪飞特科技1 小时前
【无标题】白杨尚青1 小时前
C++入门篇(十):string(上)——认识string:构造与三大遍历(一条龙讲透operator[]、迭代器、auto、范围for)FlightYe1 小时前
视界原理之2D视频(二):视频文件里有什么传奇开心果编程1 小时前
【Flutter入门练中学】第8课:动画与过渡anew___1 小时前
《从零手写操作系统 (11):文件系统初探——initrd与VFS抽象层》天天向上2911 小时前
Spring AI 实战:14 个踩坑记录,其中一个让我的测试全绿但产品是坏的正在走向自律2 小时前
从只写接口到独立交付前后端,飞算JavaAI能给Java后端工程师多少溢价?