Android - EditText 与软键盘重叠
我正在开发一个有一些 EditText 的 Activity。当我单击/触摸 EditText 时,会出现软键盘。但是屏幕底部的 EditText 与软键盘重叠。显示 EditText 的上半部分,下半部分位于键盘下方。
我在 AndroidManifest.xml 中设置了 android:windowSoftInputMode="adjustPan"
关于如何避免它有什么建议吗?
I am working on an Activity which have some EditText. When I click/touch on EditText softkeyboard appear. But the EditTexts which are at bottom of the screen, overlap with softkeyboard. Upper half of the EditText is shown and lower half is under the keyboard.
I set the android:windowSoftInputMode="adjustPan"
in AndroidManifest.xml
Any Suggestion about how to avoid it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我来说,我不想假设键盘高度是一定的尺寸。无论您关心什么视图,都创建一个 onTouchListener,然后执行以下操作:
// 本质上,我们创建一个可运行的对象,滚动到您希望在屏幕上可见的某个视图的新位置。仅当该可运行程序不在滚动视图范围内(不在屏幕上)时才执行该可运行程序。这样,它将滚动视图转移到引用的视图(在我的例子中是“someview”,它是一个行分隔符)。
For me i did not want to assume that keyboards heights are a certain measurement. Whatever view your concerned about make a onTouchListener and then do this:
//essentially we make a runnable that scrolls to a new location of some view that you WANT visible on the screen. you execute that runnable only if its not within the scrollviews bounds (its not on the screen). This way it shifts the scrollview to the referenced view (in my case 'someview' which was a line divider).