【发布时间】:2019-08-23 07:56:16
【问题描述】:
我有一个简单的 android 应用程序,其中包含相对布局和 webview:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<WebView
android:id="@+id/MyWebView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
webview中显示的页面是:
<html>
<body style="padding: 0; margin: 0; box-sizing: border-box; border: 5px solid red; width: 100vw; height: 100vh;">
test
<div style="width: 50vw; height: 70vh; border: 1px solid green;">some div</div>
<input placeholder="Type here and KB will cover this">
</body>
</html>
这是我输入文本输入时的样子。 Webview 会随着键盘的出现而调整大小。一切都按预期工作。没问题。
现在我想让应用全屏显示。我像这样更改styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowFullscreen">true</item>
</style>
应用程序现在是全屏的。但是当我点击输入时,它被软键盘覆盖,我看不到我在输入什么。
我已经尝试了所有方法(android:windowSoftInputMode="adjustResize"、adjustPan、不同的布局、在运行时更改为全屏、滚动视图)但没有任何效果。
【问题讨论】:
-
AFAIK,android 的键盘将 UI 向上推,而 iOS 覆盖在 UI 上。这是我之前遇到的问题,很遗憾无法找到解决方法。
-
参考这个链接你一定会找到有用的stackoverflow.com/questions/7417123/…