简体   繁体   中英

Android Soft Keyboard covering WebView content

I'm trying to use a WebView in my Activity to display a standard login page, however it seems that the keyboard always covers the bottom half of the page (and it doesn't allow you to 'scroll' the part that isn't covered, like you'd expect).

Looking up the issue, I've tried the usual

android:windowSoftInputMode="adjustResize"

However that doesn't seem to work. (I've tried adjustPan too)

Now I found this issue , but I have seen apps in Lollipop scroll the webview around like you'd expect to happen.

Any ideas? I'm stumped.

Edit: Also, my activity is not using the fullscreen flag.

Here is my Activity's XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_height="56dp"
        android:layout_width="match_parent"
        android:paddingTop="25dp"
        android:fitsSystemWindows="true"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:background="?attr/colorPrimary" />


    <WebView
        android:id="@+id/webview_login"
        android:fitsSystemWindows="true"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>

maybe you can overwrite the method named onSizeChanged() as following:

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    if (onSizeChangedListener != null) {
        onSizeChangedListener.onSizeChanged(w, h, oldw, oldh);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM