【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)
}
相关推荐
清空mega2 小时前
第15章 综合项目——网上订餐系统
android
f***45324 小时前
基于SpringBoot和PostGIS的各省与地级市空间距离分析
android·前端·后端
珹洺5 小时前
Java-Spring入门指南(三十一)Android意图(Intent)
android·java·spring
b***9106 小时前
【SpringBoot3】Spring Boot 3.0 集成 Mybatis Plus
android·前端·后端·mybatis
q***73557 小时前
删除文件夹,被提示“需要来自 TrustedInstaller 的权限。。。”的解决方案
android·前端·后端
Android系统攻城狮7 小时前
Android内核进阶之获取当前PCM周期snd_pcm_lib_period_bytes:用法实例(九十三)
android·pcm·android内核·音频进阶·alsa音频
源码君miui520867 小时前
JAVA国际版同城服务同城信息同城任务发布平台APP源码Android + IOS
android·java·ios
FrameNotWork8 小时前
Android Repo Manifest 文件详解(基于 Redroid 定制示例)
android
沐怡旸9 小时前
【底层机制】Android OTA更新系统:原理与应用深度解析
android·面试
q***311410 小时前
【Springboot3+vue3】从零到一搭建Springboot3+vue3前后端分离项目之后端环境搭建
android·前端·后端