任何方法都可以“修复” Android 的键盘处理能力如何?
首先,我知道关于 android 键盘的大约 1000 个其他问题...我知道我可以从窗口或控件中手动隐藏键盘,并传入任意数量的标志来控制键盘弹出的位置和时间。
基本上,我的目标是在我的应用程序中进行可预测的键盘处理...也就是说,除非明确告知要聚焦此控件和弹出键盘,否则它只会在用户点击文本编辑时才会弹出。
这个应用程序非常广泛,并且手动尝试隐藏键盘,甚至只是聚焦控件(而不是显式隐藏每个编辑字段)。
我也知道,当您不希望弹出键盘出现时,我可以通过将焦点设置在非文本可编辑字段上来避免弹出键盘,但是,这看起来更像是一种黑客行为。
所以我的问题是...有没有一种方法可以强制应用程序永远不会在新对话框、片段等上自动弹出键盘...应用程序范围内?如果我希望此文本字段集中在新对话框上,我将手动处理这些情况。另外,当先前聚焦的控件消失时,有什么方法可以自动处理键盘消失吗?
我只是不明白那里的逻辑......如果我退后一步思考这一点,我只想在我想输入一些东西时弹出键盘。至于当新对话框打开时键盘立即弹出......似乎是例外情况(可能有几次我想这样做)。
我不介意构建一个管理器或跟踪键盘状态的东西,但是我不知道我是否可以获得使其以远程直观的方式高效工作所需的信息。
任何指示或想法将不胜感激......因为我对此一无所知......我可以向你保证我已经花了很多时间研究这个并尝试修复。
注意:对标题或敌意感到抱歉...我已经为此奋斗了相当长一段时间,并且通常对键盘处理的怪异感到愤怒。
First of all, I am aware of about 1000 other questions regarding the android keyboard... I am aware I can manually hide keyboard from window or control, and pass in any number of flags that are supposed to control where and when keyboard pops up.
Basically, I aim to have PREDICTABLE keyboard handling in my app... that is that unless explicitly told to focus this control, and popup keyboard, it'll only pop up when a user taps a text edit.
This app is extensive, and manually attempting to hide keyboard from even just the focused control (vs explicitly hiding each and every edit field).
I am also aware I can avoid the popup up keyboard when you dont want it there, by setting focus on a non text editable field, however, that seems like more of a hack than anything else.
So my question is... is there a way to just force app to never auto pop up keyboard on new dialogs, fragments etc... app wide? If I want this text field to et focus on new dialog, I'll manually handle those cases. In addition, any way to automatically handle keyboard dissapear when the previously focused control dissapears?
I just dont get logic there... if I step back and think about this, I'd only want keyboard popping up if I wanted to go type something. As far as keyboard popping up immediately when new dialog opens... seems like the exceptional case (there may be a couple times I'd want to do that).
I dont mind building a manager or something that keeps track of the state of keyboard, however i dont know if I can get at the information I'd need to make it work in a remotely intuitive manner, efficiently.
Any pointers or ideas would be greatly appreciated... because I am at my whits end with this... and I can assure you I've spent a good deal of time researching this and attempting fixes.
Note: Sorry about the title or hostility... I've fought this for quite some time, and been generally infuriated with how bizarre dealing with the keyboard can be.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不。
但您可以在每个活动上使用:
。
No.
But you can use:
On each activity.
好吧,我想我明白你的要求了。看看这里的第二个答案:
Stop EditText from getting focus at Activity启动
您可以在 AndroidManifest.xml 中指定是否应隐藏软键盘,方法是将此
android:windowSoftInputMode="stateHidden"
添加到活动标记的开头(<活动>
)Ok, I think I get what you're asking. Have a look at the second answer here:
Stop EditText from gaining focus at Activity startup
You can specify in your AndroidManifest.xml whether or not the softkeyboard should be hidden by adding this
android:windowSoftInputMode="stateHidden"
to the beginning of your activities tag (<activity>
)