简体   繁体   中英

Resize the layout when the keyboard opens

I want to resize my activity layout when the soft keyboard opens. I tried putting this in the manifest :

android:windowSoftInputMode="adjustResize"

but it doesn't work. And this is my xml layout :

<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"
    android:fitsSystemWindows="true"
    tools:context=".ui.SettingsActivity">

    <!-- BODY -->
    <ScrollView
        android:id="@+id/scrollViewBody"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <!-- my list -->

        </LinearLayout>
    </ScrollView>

    <!-- TOOLBAR -->
    <include layout="@layout/toolbar" />

Layout does not resize when keyboard opens... Help me please

From the documentation

"adjustResize" The activity's main window is always resized to make room for the soft keyboard on screen.

"adjustPan" The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.

I believe what you want is adjustPan .

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