【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)
}
相关推荐
禾叙_19 小时前
【canal】canal同步msyql到redis
android·redis·python
下位子20 小时前
『OpenGL学习滤镜相机』- Day 12: LUT 滤镜(Look-Up Table)
android·opengl
下位子20 小时前
『OpenGL学习滤镜相机』- Day 11: 实时滤镜效果
android·opengl
shankss21 小时前
GetX 状态管理详解
android·flutter·ios
坚持学习前端日记21 小时前
原生Android开发与JS桥开发对比分析
android·开发语言·javascript
、、、、南山小雨、、、、1 天前
LCEL基本使用和高级使用
android·服务器·windows
Franciz小测测1 天前
Gemini 网页端自定义教程:利用 Stylus 强制开启宽屏显示
前端·css·stylus
Android-Flutter1 天前
android compose CheckBox, RadioGroup 使用
android·kotlin
ljt27249606611 天前
Compose笔记(六十六)--ModalNavigationDrawer
android·笔记·android jetpack
Android-Flutter1 天前
android compose Tab(顶部) 使用
android·kotlin