【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)
}
相关推荐
Jerry1 天前
Compose 5 个简短动画,让您的应用脱颖而出
android
PenguinLetsGo1 天前
你的App是否有出现过幽灵调用?
android
没有了遇见1 天前
Android ViewPager2 嵌套 RecyclerView 滑动冲突解决方案
android
咖啡の猫1 天前
Android开发-选择按钮
android·gitee
火柴就是我1 天前
android 以maven的方式 引入本地的aar
android
过-眼-云-烟1 天前
新版Android Studio能打包但无法run ‘app‘,编译通过后手机中没有安装,顶部一直转圈
android·ide·android studio
hedalei1 天前
android14 硬键盘ESC改BACK按键返回无效问题
android·android14·esc·back按键
hcgeng1 天前
android 如何判定底部导航栏显示时 不是键盘显示
android·底部导航·导航高度
和煦的春风1 天前
性能案例分析 | Waiting for GPU completion
android·linux
用户2018792831671 天前
ConcurrentHashMap:用 “社区超市” 故事讲透并发的设计哲学
android