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);
    }
相关推荐
listhi52013 分钟前
Vue.js 3的组合式API
android·vue.js·flutter
用户693717500138427 分钟前
🚀 Jetpack MVI 实战全解析:一次彻底搞懂 MVI 架构,让状态管理像点奶茶一样丝滑!
android·android jetpack
fantasy5_51 小时前
手撕vector:从零实现一个C++动态数组
java·开发语言·c++
十八旬1 小时前
RuoYi-Vue3项目定制修改全攻略
java·windows
任风雨1 小时前
3.1.1.Java基础知识
java·开发语言
脸大是真的好~1 小时前
黑马JAVA+AI 加强03-集合-Collection-List和Set集合-迭代器(Iterator)遍历-并发修改异常
java
2501_915918412 小时前
iOS 上架应用市场全流程指南,App Store 审核机制、证书管理与跨平台免 Mac 上传发布方案(含开心上架实战)
android·macos·ios·小程序·uni-app·cocoa·iphone
cj6341181502 小时前
DBeaver连接本地MySQL、创建数据库表的基础操作
java·后端
峥嵘life2 小时前
Android EDLA 打开5G热点失败分析解决2
android·5g
书院门前细致的苹果2 小时前
深入理解 Java 多线程与线程池 —— 从原理到实战
java·开发语言