【Android】手写笔适配

以下代码分别用于检测

  • 是否为手写笔事件
  • 是否为橡皮擦事件
  • 是否为手写笔主按钮
  • 是否为手写笔辅按钮
kotlin 复制代码
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
  val isStylus = event.getToolType(event.actionIndex) == MotionEvent.TOOL_TYPE_STYLUS
  val isEraser = event.getToolType(event.actionIndex) == MotionEvent.TOOL_TYPE_ERASER
  val isStylusPrimaryButton = event.buttonState == MotionEvent.BUTTON_STYLUS_PRIMARY
  val isStylusSecondaryButton = event.buttonState == MotionEvent.BUTTON_STYLUS_SECONDARY
  return super.dispatchTouchEvent(event)
}
相关推荐
2501_937193149 小时前
技术加持!PLB-TV:HDR10+UDP 传输
android·源码·源代码管理·机顶盒
霸王大陆11 小时前
《零基础学 PHP:从入门到实战》模块十:从应用到精通——掌握PHP进阶技术与现代化开发实战-2
android·开发语言·php
低调小一14 小时前
在 Android 上获取视频流逐帧时间戳并与 GPS/IMU 对齐(CameraX 实践)
android
Android_Trot15 小时前
Flutter android 多渠道配置,多包名、icon、等配置。
android·flutter
zhangphil16 小时前
Android性能:trace上的锁竞争monitor contention with owner at
android
砖厂小工17 小时前
Now In Android 精讲 9 - Benchmark 与 Baseline Profile
android
愤怒的代码17 小时前
深入解析 SystemUI 依赖注入:Dagger2 与 Hilt 核心机制重温
android·dagger
從南走到北19 小时前
JAVA海外短剧国际版源码支持H5+Android+IOS
android·java·ios
霸王大陆19 小时前
《零基础学 PHP:从入门到实战》模块十:从应用到精通——掌握PHP进阶技术与现代化开发实战-1
android·开发语言·php