android鼠标滚轮事件监听方法

复制代码
@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);
    }
相关推荐
hunterandroid4 小时前
Android 多渠道打包与 Gradle 构建优化实战
android·前端·kotlin
Zane19944 小时前
自己写一个 java.lang.String,为什么永远替换不掉 JDK 那个
java·后端
小白羊丨4 小时前
异步任务创建接口如何幂等?
android·数据库
吴声子夜歌4 小时前
Guava——并发(一)
java·guava
天空属于哈夫克34 小时前
企业微信API:企业微信如何实现自动化运营?
java·自动化·企业微信
lhldsg4 小时前
相册印刷实战指南:从设计规范到系统落地全流程解析
java·小程序·架构·设计规范
vipxieliang4 小时前
订单数据验证:从购物车到支付的完整验证链路
java·spring boot
草青工作室4 小时前
java-不携带Token也能“打“自己的接口:一个绕开网关鉴权、用 URL 直接调度 SpringMVC 方法的轻量级定时任务方案
java·开发语言
用户0934077735144 小时前
HarmonyOS WPS Open SDK 实践:把水印与修订收成打开策略层
android·typescript·harmonyos
sumatch4 小时前
ESP32
android