lorinet3
lorinet3

Reputation: 442

android:windowSoftInputMode="adjustResize" gets ignored

My View contains only a WebView which is set to maximum width and height, and I added android:windowSoftInputMode="adjustResize" to activity_main.xml, but it didn't work. I also tried with adjustPan, but that got ignored too. My WebView contains a site with a text box at the bottom, and when I activate the text box, the on-screen keyboard should appear and the screen should resize/get pushed up so that the text box will still be visible. Instead, the keyboard appears over the content and obscures the text box, not allowing the user to see what they type.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
    android:windowSoftInputMode="adjustResize"
    tools:context=".MainActivity">

    <WebView
        android:id="@+id/nebView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:scrollbars="none"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

Upvotes: 0

Views: 1482

Answers (1)

J. Hegg
J. Hegg

Reputation: 2073

You need to set it either programatically in the activity

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

or right in the manifest

<application ... >
<activity
    android:windowSoftInputMode="adjustResize" ... >
    ...
</activity>
...

You can find further informations here --> https://developer.android.com/training/keyboard-input/visibility

Upvotes: 0

Related Questions