Android webview键盘覆盖输入 [英] Android webview keyboard covering up input

查看:1341
本文介绍了Android webview键盘覆盖输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Android应用程序的期望效果是有一个带有输入框和内容的webview。当用户点击键盘时,键盘会将输入框向上推,但不会调整主要内容,而只是调整其上方的叠加层,如下图所示。





我遇到的问题是,键盘覆盖了输入框,不会推动它。



这是目前的cordova Android应用程式。在清单中,我已配置

 < activity android:configChanges =orientation | keyboardHidden | keyboard | screenSize | localeandroid :label =@ string / activity_nameandroid:launchMode =singleInstanceandroid:name =GigJamandroid:theme =@ android:style / Theme.DeviceDefault.NoActionBarandroid:windowSoftInputMode =adjustPan> 

同样在config.xml中:

 < preference name =Fullscreenvalue =false/> 



我使用android:windowSoftInputMode =adjustPan防止屏幕调整大小,这是我想要的我不想让内容被压扁。我也试过配置输入框的css是固定的和绝对的(基本上绑定在webview的底部。



从我的理解,当键盘弹出



在输入框中编辑的时候,它会向上推动框,因为输入框被约束到webview。任何建议赞赏,
谢谢,
D

解决方案

Android有一个我听的键盘事件。当显示/隐藏被触发时,我抓住活动输入组件,并在y轴的框中转换键盘高度的大小,这可以从监听器中的事件中抓取。 / p>

注意:resize需要为android:windowSoftInputMode禁用,并设置为adjustPan


The desired effect for my android application is to have a webview with an input box and content. When the user clicks on the keyboard, the keyboard pushes the input box up, but does not resize the main content and just overlays ontop of it as seen in the diagram below.

The problem I'm experiencing is that the keyboard covers the input box and does not push it up.

This is currently a cordova android application. In the manifest, I have configued

 <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleInstance" android:name="GigJam" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustPan">

Also in the config.xml:

   <preference name="Fullscreen" value="false" />

I used android:windowSoftInputMode="adjustPan" to prevent the screen from resizing which is what i want since I don't want the content to be squished. I've also tried configuring the css for the input box to be fixed and absolute (basically tied to the bottom of the webview.

From my understanding, when the keyboard pops up from an edit in the input box, that it would push up the box as well because the input box is constrained to the webview which will be pushed up as well.

Any advice appreciated, Thanks, D

解决方案

Android has a keyboard event that I listen to. When the show/hide is trigger, I grab the active input component and transform the box in the y axis by the size of the keyboard height which can be grab from the event in the listener. I transform back when the show is triggered.

Note: resize needs to be disabled for the android:windowSoftInputMode and set to "adjustPan"

这篇关于Android webview键盘覆盖输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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