【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)
}
相关推荐
weiggle9 小时前
第七篇:状态提升与单向数据流——架构设计的核心
android
xingpanvip9 小时前
星盘接口开发文档:本命盘接口指南
android·开发语言·css·php·lua
goldenrolan9 小时前
A公司物料替代测试系统 v1.7:从需求到 exe/apk 的 AI 辅助全链路实践
android·自动化测试·软件测试·python·ai
AC赳赳老秦10 小时前
用 OpenClaw 搭建服务器故障应急响应系统,自动处理 80% 常见运维故障
android·运维·服务器·python·rxjava·deepseek·openclaw
骇客之技术11 小时前
AutoLua:在安卓上写 Lua 脚本
android·junit·lua
kiros_wang12 小时前
Android 常见面试题
android
货拉拉技术13 小时前
Hook植入日志协助定位问题方案
android
FlightYe13 小时前
Android投屏MirrorCast全链路
android
Ehtan_Zheng13 小时前
Kotlin const val vs val:字节码、性能与隐藏陷阱详解
android·kotlin
墨狂之逸才13 小时前
Android TV 垃圾应用清理指南
android