【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)
}
相关推荐
程序员码歌7 小时前
短思考第263天,每天复盘10分钟,胜过盲目努力一整年
android·前端·后端
安卓兼职framework应用工程师7 小时前
Android 10.0 按键智能机按键连续响两次的异常处理
android·audio·audioservice·按键音·按键声音
studyForMokey7 小时前
【Android 项目】个人学习demo随笔
android
吃喝不愁霸王餐APP开发者7 小时前
利用责任链模式解耦多平台(美团/饿了么)霸王餐接口的适配逻辑
android·责任链模式
百***78757 小时前
Step-Audio-2 轻量化接入全流程详解
android·java·gpt·php·llama
yangpipi-10 小时前
《C++并发编程实战》第5章 C++内存模型和原子操作
android·java·c++
云水木石12 小时前
Android 的下一个战场:Windows 应用与游戏?
android·windows·游戏
雨声不在12 小时前
Android文字渐变的实现
android·textview
GoldenPlayer12 小时前
KTS语法
android
GoldenPlayer12 小时前
后台服务Service销毁逻辑+单例造成的内存泄露
android