【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_9159184113 分钟前
只有 Flutter IPA 文件,通过多工具组合完成有效混淆与保护
android·flutter·ios·小程序·uni-app·iphone·webview
robotx37 分钟前
AOSP 设置-提示音和振动 添加一个带有开关(Switch)的设置项
android
青莲84342 分钟前
RecyclerView 完全指南
android·前端·面试
青莲84343 分钟前
Android WebView 混合开发完整指南
android·前端·面试
龙之叶1 小时前
【Android Monkey源码解析三】- 运行解析
android
KevinWang_2 小时前
Android 的 assets 资源和 raw 资源有什么区别?
android
码农幻想梦3 小时前
2021Android从零入门到实战(慕课网官方账号)
android
Jomurphys3 小时前
Android 架构 - 组件化 Modularzation
android
明明明h3 小时前
【Unity3D】Android App Bundle(aab)打包上架Google Play介绍
android
花卷HJ4 小时前
Android 通用 RecyclerView Adapter 实现(支持 ViewBinding + 泛型 + 点击事件)
android