问题
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