java - 键盘打开时 WebView 调整屏幕大小

标签 java android webview

我在我的 Android 应用程序中使用 WebView。我想显示一个具有 EditTest 的网站。当我运行我的应用程序时,它运行良好,但是当我单击 EditText 时,我的键盘打开,并且我的 WebView 不调整大小。 这是我的 .xml 文件

<android.support.v4.widget.DrawerLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".FacebookNewWrapper" >

<!-- Our actual WebView -->

<RelativeLayout
    android:id="@+id/webview_container"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <com.facebook.FacebookWebView
        android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fadeScrollbars="true"
        android:focusable="true"
        android:focusableInTouchMode="true" />

    <!-- Progress bar used to show the loading progress -->

    <ProgressBar
        android:id="@+id/progress_bar"
        style="@style/Widget.Tinfoil.ProgressBar"
        android:layout_width="fill_parent"
        android:layout_height="@dimen/webview_top_progress_bar"
        android:layout_alignParentTop="true" />
</RelativeLayout>
<!-- Mostly use for full-screen video playback -->

<FrameLayout
    android:id="@+id/fullscreen_custom_content"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/black"
    android:visibility="gone" />

<!-- Menu drawer (right) -->

<include layout="@layout/drawer_menu" />

我已添加

 android:configChanges="orientation|keyboardHidden"
 android:launchMode="standard"
 android:windowSoftInputMode="adjustPan"

将其放入我的 Android Menifest.xml 中 并将其添加到我的 .java 文件中

   getWindow().setSoftInputMode(
            WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);

但没有什么对我有帮助。 我该如何解决我的问题。

最佳答案

从 .java 文件中删除

getWindow().setSoftInputMode(
            WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);

在 Android Manifest.xml 中查找

android:windowSoftInputMode="adjustPan"

更改为

android:windowSoftInputMode="adjustResize"

关于java - 键盘打开时 WebView 调整屏幕大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28517980/

相关文章:

java - Hibernate,从不同表到通用表的一对多

android - Flutter 应用程序的小部件架构

android - 相机的 SurfaceView 与 TextureView?

ios - 多进程iOS应用程序

java - 如何查看从 Neo4J Java 应用程序创建的节点的可视化图形表示?

java - 打印输入与数组元素匹配的整行

java - 用于检查字符串是否具有一定位数的正则表达式

java - Android - 获取 View 的可见区域?

android - 为 Android WebView 启用第三方 cookie

javascript - android webview = 找不到网页 = 在哪里添加 onReceivedError