Android SoftKeyboardDetect: Ignore this event what does it mean?

只愿长相守 提交于 2020-01-11 12:04:06

问题


I see this debug message frequently in LogCat. When doing swipe or rotating the device for example. The emulator doesn't react to the events then. What does it mean?

In need to test rotation on the emulator but on some versions, when I press CTRL F12 or CTRL F11 nothing happens (well, the device rotates as a whole but not the screen) and I see this message in log. I don't find anything with google either...

Ok, it's PhoneGap specific. I found something in the source code of PhoneGap:

 /**
  * We are providing this class to detect when the soft keyboard is shown 
  * and hidden in the web view.
  */
 class LinearLayoutSoftKeyboardDetect extends LinearLayout {

        private static final String TAG = "SoftKeyboardDetect";

But I'm not doing anything with soft keyboard, I'm just rotating the device. It's a bug maybe?


回答1:


I can give you the background on this log. There is a bug in Android or maybe they'd call it a lack of feature but there is no event thrown when the keyboard is shown or goes away. This causes a problem for web applications as the keyboard shortens the the screen size. When the screen size becomes smaller then your UI suffers.

In order to be able to react to the keyboard show/hide in PhoneGap Android we implemented the LinearLayoutSoftKeyboardDetect which is basically a LinearLayout but it reacts to changes in the screen size. If you rotate the device the width becomes the height and we can ignore the change but if the height gets dramatically smaller while the width remains the same it is safe to assume there is a keyboard being shown and we throw a show keyboard event. When the height gets dramatically larger while width stays the same we throw a hide keyboard event. Make sense?




回答2:


This implementation seems affect with the situation -> When native keyboard is pop up it shrink the webview in phonegap. Again demention changes. So it tends to ignore necessary events. I want to detect native keyboard done button press event.



来源:https://stackoverflow.com/questions/9333689/android-softkeyboarddetect-ignore-this-event-what-does-it-mean

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