使用Android软键盘键入时的touchEvent [英] touchEvent while typing with soft keyboard android

查看:84
本文介绍了使用Android软键盘键入时的touchEvent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,当用户在TextView上使用其软键盘键入内容时,我想接收touchEvent(MotionEvent)事件.我已经尝试在主要活动上使用dispatchTouchEvent(MotionEvent),但是在键入期间不会触发此事件.有办法处理吗?

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?

主要思想是在软键中具有两个不同的事件,一个用于提交的字母(例如,对于keyUp和keyDown),另一个相对于触摸(例如dispatchTouchEvent),因为当您按下一个字母时,您触摸了屏幕,这意味着您应该出现一个dispatchTouchEvent或类似的东西.

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.

推荐答案

无法从软键盘获取触摸事件,因为Android键盘基本上是已经消耗其触摸事件的独立Android应用.但是,您可以使用 onKeyDown http://developer.android.com/training/keyboard-input/commands.html

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

这篇关于使用Android软键盘键入时的touchEvent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆