如何使滑动抽屉远离虚拟键盘顶部
我一整天都在为这件事摸不着头脑。在我的一项活动(而且只有一项)中,当我调用虚拟键盘时,滑动抽屉手柄会出现在其上方。我设法在我的应用程序中的所有其他活动上解决此问题,方法是将 android:windowSoftInputMode="adjustPan" 放入我的 Manafest.xml 文件中的每个活动(包括有问题的活动)中。据我所知,活动中没有一个对象具有焦点(如果有的话,我不知道如何找到它)。我通过使用 this.getCurrentFocus() 检查焦点,然后在返回的视图上执行 view.clearFocus() (如果有的话)。到目前为止,据我所知,它还没有返回视图,没有任何焦点。
有什么想法吗?
I've been scratching my head all day over this. on one of my activities (and only one) when i call up the virtual keyboard the sliding drawer handle appears above it. i managed to fix this problem on all the other activities in my app by putting android:windowSoftInputMode="adjustPan" in every activity in my Manafest.xml file including the activity in question. also as far as i've been able to determine none of the objects on the activity has focus (if one does i cant figure out how to find it). i've checked for focus by using this.getCurrentFocus() then doing view.clearFocus() on the returned view if there was one. so far it hasn't returned a view so as far as i can tell nothing has focus.
any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我的解决方法。在保存 EditText 的 Activity 中,我有一个扩展
EditText
的子类。在这个子类中,我重写了 onMeasure() 方法,该方法检查键盘是否打开。然后在活动中,如果键盘打开,则抽屉手柄设置为 1px x 1px 透明图像,如果键盘隐藏,则显示真实手柄:
最后,确保调用
setContext()
在MyActivity
的onCreate()
中This is my workaround.. in the Activity that holds the EditText I have a subclass that extends
EditText
. In this subclass I override theonMeasure()
method which checks to see if the keyboard is open.Then in the activity, if the keyboard is open the drawer handle is set to a 1px x 1px transparent image, if the keyboard is hidden the real handle is shown:
Finally, make sure you call
setContext()
inonCreate()
ofMyActivity