touchEvent while typing with soft keyboard android

别来无恙 提交于 2020-01-06 03:06:11

问题


in my application I would like to receive touchEvent(MotionEvent) event while the user is typing using his soft keyboard on a TextView. I have already tried using dispatchTouchEvent(MotionEvent) on the main activity, but during the typing this event is not fired. Is there a way to handle it?

EDIT: The main idea is to have from the soft key two different events, one for the letter submitted (for example as with keyUp and keyDown) and one relative to the touch like dispatchTouchEvent, since when you press for a letter you touch the screen, meaning that you should arise a dispatchTouchEvent or something similar.


回答1:


It's not possible to get touch events from the soft keyboard as Android keyboards are basically separate Android apps that already consume their touch events. However you can react on their key presses using the onKeyDown and onKeyUp events. See also http://developer.android.com/training/keyboard-input/commands.html



来源:https://stackoverflow.com/questions/25961220/touchevent-while-typing-with-soft-keyboard-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!