Android:如何防止软键盘将我的视图向上推? [英] Android: How do I prevent the soft keyboard from pushing my view up?

查看:34
本文介绍了Android:如何防止软键盘将我的视图向上推?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用底部有一个垂直滑动抽屉.当软键盘打开时,它会将抽屉的拉片向上推,因此它位于键盘顶部.我实际上希望它保留在屏幕底部,在显示键盘时隐藏.

I have a vertical sliding drawer at the bottom of my app. When the soft keyboard opens, it pushes the tab for the drawer up, so it sits atop the keyboard. I actually want it to remain at the bottom of the screen, becoming hidden when the keyboard is shown.

还有其他人遇到过这个问题吗?知道如何解决吗?

Anyone else run into this issue? Know how to fix it?

推荐答案

您可以简单地将您的 Activity 的 windowSoftInputMode 标志切换到 AndroidMainfest.xml<中的 adjustPan/code> 活动标签中的文件.

You can simply switch your Activity's windowSoftInputModeflag to adjustPan in your AndroidMainfest.xml file inside your activity tag.

查看官方文档了解更多信息.

<activity
   ...
   android:windowSoftInputMode="adjustPan"> 
</activity>

如果您的容器没有改变大小,那么您可能将高度设置为匹配父级".如果可能,请将父级设置为Wrap Content",或将约束设置为父级顶部和底部的约束布局.

If your container is not changing size, then you likely have the height set to "match parent". If possible, set the parent to "Wrap Content", or a constraint layout with constraingts to top and bottom of parent.

父容器将缩小以适应可用空间,因此您的内容很可能应位于滚动视图内以防止(取决于手机制造商和选择的布局...)

The parent container will shrink to fit the available space, so it is likely that your content should be inside of a scolling view to prevent (depending on the phone manufacturer and the layout choosen...)

  1. 内容被粉碎
  2. 挂在屏幕上的内容
  3. 内容因位于键盘下方而无法访问

即使它所在的布局是相对或约束布局,内容也可能会出现问题 1-3.

even if the layout it is in is a relative or constraint layout, the content could exhibit problems 1-3.

这篇关于Android:如何防止软键盘将我的视图向上推?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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