当键盘出现时,Webview未能自动调整大小

9
需要调整我的webview大小,使其在键盘出现时类似于Cordova/Phonegap。 目前根据下面的代码,我的输入文本字段被设备键盘覆盖。我想压缩webview的高度,并使其在设备键盘上方自适应高度。
活动代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg_home">

<include android:id="@+id/head" layout="@layout/header" />

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="11dp"
    android:layout_marginLeft="11dp"
    android:layout_marginRight="11dp"
    android:layout_marginTop="2dp"
    android:layout_below="@id/head"
    android:background="@drawable/overlay_bg2"
    android:orientation="vertical"
    android:padding="9dp" >

    <WebView
        android:id="@+id/webView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:layout_gravity="center"
        android:isScrollContainer="true"/>

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyleLargeInverse"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:visibility="invisible" />

</FrameLayout>

</RelativeLayout>

清单项:
主题 android:theme="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"


键盘控制活动 android:windowSoftInputMode="adjustResize"


请尝试使用android:windowSoftInputMode="adjustResize|stateHidden" - Skizo-ozᴉʞS ツ
不,它没有起作用。 我需要将整个Web视图布局挤入键盘上方的区域。 - Abhinav Tyagi
它不起作用。我尝试了不同状态和调整的组合。 Cordova 是如何做到的? - Abhinav Tyagi
查看他在此 链接 中所说的内容... - Skizo-ozᴉʞS ツ
你可以在这里找到解决方案:https://stackoverflow.com/a/57623505/3819714 - Reza Roshan
显示剩余3条评论
1个回答

3
据我所知,如果您的活动(或整个应用程序)设置为全屏,则android:windowSoftInputMode="adjustResize"将无效。

有没有解决方案? - sandeepmaaram
请确保在您的Web视图中不使用CSS的绝对定位。 - Karlth

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接