【问题标题】:Unwanted Top and Bottom White Space in Android Webview after keyboard disappears键盘消失后Android Webview中不需要的顶部和底部空白
【发布时间】:2018-11-29 08:43:23
【问题描述】:

参考 SO 问题:remove-unwanted-white-space-in-webview-androidandroid-webview-has-extra-white-space-at-the-bottom

我正在使用 NativeScript 进行 Angular 移动应用程序开发。我有一个在 webview 中呈现的登录页面,一旦应用程序拥有令牌,应用程序就会重定向到其他本机组件。

我的问题是:屏幕第一次呈现正常,当用户单击任何文本字段时,会出现键盘,但是当用户按下 Android Back 按钮隐藏键盘时,它会在顶部和底部显示空白页面。

根据上述线程提供的建议,我尝试将填充和边距设置为 0。 和

<meta name="viewport" content="target-densityDpi=device-dpi, width=device-width, height=device-height, initial-scale=1">

【问题讨论】:

  • 当你专注于 webview 中的文本字段时?我无法重现该问题,您能否更新Playground example 以便我们查看该问题。
  • 当我们按下后退按钮关闭键盘时,尝试在 html 中为 body 设置一些背景颜色。很快就会更新游乐场
  • 这正是我尝试过的,我使用的是 Android 8。
  • 感谢 Manoj,那个游乐场确实帮助了我。看起来我的 webview 在 GridLayout 内,并将该布局的高度设置为 100% 解决了这个问题。

标签: webview nativescript nativescript-angular


【解决方案1】:

感谢 Playground Manoj。 看起来 html 页面中存在百分比高度和宽度,每次用户从 html 页面移出时,它都会重新调整自身以适应可用空间,有时也会挤压。

我在 GridLayout 中使用 webview 并将高度和宽度 100% 设置为 GridLayout 解决了我的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-19
    • 1970-01-01
    • 1970-01-01
    • 2017-12-08
    • 1970-01-01
    • 2021-06-03
    • 2019-05-04
    相关资源
    最近更新 更多