Coordinatorlayout adjustResize not collapsing toolbar when opening keyboard

scrollview not working when keyboard open in android
adjustresize not working
how to scroll view up when keyboard appears android
adjustresize constraintlayout
adjustpan not working
scroll when keyboard open android
scroll edittext above keyboard android
layout of the screen moves up when keyboard is displayed

I have the following layout in my android app but I have a problem with windowSoftInputMode="adjustResize" in the activity. The layout contains a next button at the bottom of the screen. When the keyboard is opened, the button is overlapping the input fields instead of collapsing the toolbar.

I've tried

  • adding android:fitsSystemWindows="true" to the parent layout

  • setting adjustPan in the manifest

  • wrapping the constraintlayout and button in a nestedscrollview

  • wrapping the coordinatorlayout in a Relativelayout

  • Read:

    • adjustResize does not work with CoordinatorLayout
    • Coordinatorlayout adjustresize not working

Remarks:

The funny thing is, when I'm typing something in the first EditText field, when the text goes past the default width, only then it does resize the toolbar and collapses it.

<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.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/save_button">

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

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <TextView
            android:id="@+id/report_input_name_hint"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginEnd="16dp"
            android:layout_marginStart="16dp"
            android:layout_marginTop="16dp"
            android:fontFamily="@font/customfont"
            android:text="@string/report_phonenumber_name_hint"
            android:textColor="@color/light_grey"
            android:visibility="invisible"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <EditText
            android:id="@+id/report_input_name"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginTop="8dp"
            android:background="@android:color/transparent"
            android:fontFamily="@font/customfont"
            android:hint="@string/report_phonenumber_name_hint"
            android:inputType="textPersonName"
            android:maxLength="120"
            android:textColorHint="@color/text_color_hint"
            android:textSize="@dimen/text_18sp"
            app:layout_constraintEnd_toStartOf="@+id/clear_text_button_name"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/report_input_name_hint" />

        <ImageView
            android:id="@+id/clear_text_button_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:contentDescription="@string/accessibility_image_description_clear_text_button"
            android:padding="@dimen/linespace_10dp"
            android:visibility="invisible"
            app:layout_constraintBottom_toBottomOf="@+id/report_input_name"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="@+id/report_input_name"
            app:srcCompat="@drawable/icn_pro_cross" />

        <View
            android:id="@+id/textview_underline_name"
            android:layout_width="0dp"
            android:layout_height="1dp"
            android:layout_marginEnd="8dp"
            android:layout_marginTop="8dp"
            android:background="@color/light_grey"
            app:layout_constraintEnd_toEndOf="@+id/clear_text_button_name"
            app:layout_constraintStart_toStartOf="@+id/report_input_name"
            app:layout_constraintTop_toBottomOf="@+id/report_input_name" />

        <android.support.constraint.Barrier
            android:id="@+id/barrier2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:barrierDirection="bottom"
            app:constraint_referenced_ids="report_input_name,textview_underline_name,clear_text_button_name,report_input_name_hint"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/textview_underline_name" />

        <TextView
            android:id="@+id/report_input_number_hint"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginEnd="16dp"
            android:layout_marginStart="16dp"
            android:layout_marginTop="16dp"
            android:fontFamily="@font/customfont"
            android:text="@string/telefoonnummer"
            android:textColor="@color/light_grey"
            android:visibility="invisible"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="@+id/barrier2" />

        <ImageView
            android:id="@+id/country_flag"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:adjustViewBounds="false"
            android:contentDescription="@string/accessibility_image_description_country_flag"
            android:padding="@dimen/linespace_10dp"
            android:src="@drawable/flag_netherlands"
            app:layout_constraintBottom_toBottomOf="@+id/report_input_number"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="@+id/report_input_number" />

        <ImageView
            android:id="@+id/dropdown_arrow"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:rotation="90"
            android:src="@drawable/dropdown_arrow"
            app:layout_constraintBottom_toBottomOf="@+id/country_flag"
            app:layout_constraintStart_toEndOf="@+id/country_flag"
            app:layout_constraintTop_toTopOf="@+id/country_flag"
            tools:ignore="ContentDescription" />

        <TextView
            android:id="@+id/country_code"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="4dp"
            android:fontFamily="@font/customfont"
            android:text="@string/report_phone_dutch_country_code"
            android:textColor="@color/dark_text"
            android:textSize="@dimen/text_18sp"
            app:layout_constraintBottom_toBottomOf="@+id/report_input_number"
            app:layout_constraintStart_toEndOf="@+id/dropdown_arrow"
            app:layout_constraintTop_toTopOf="@+id/report_input_number" />

        <EditText
            android:id="@+id/report_input_number"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:background="@android:color/transparent"
            android:focusable="true"
            android:fontFamily="@font/customfont"
            android:hint="@string/report_phone_text_hint"
            android:inputType="number"
            android:maxLength="13"
            android:textColorHint="@color/text_color_hint"
            android:textSize="@dimen/text_18sp"
            app:layout_constraintEnd_toStartOf="@+id/clear_text_button"
            app:layout_constraintStart_toEndOf="@+id/country_code"
            app:layout_constraintTop_toBottomOf="@+id/report_input_number_hint" />

        <ImageView
            android:id="@+id/clear_text_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:contentDescription="@string/accessibility_image_description_clear_text_button"
            android:padding="@dimen/linespace_10dp"
            android:visibility="invisible"
            app:layout_constraintBottom_toBottomOf="@+id/report_input_number"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="@+id/report_input_number"
            app:srcCompat="@drawable/icn_pro_cross" />

        <View
            android:id="@+id/textview_underline_number"
            android:layout_width="0dp"
            android:layout_height="1dp"
            android:layout_marginEnd="8dp"
            android:layout_marginTop="8dp"
            android:background="@color/light_grey"
            app:layout_constraintEnd_toEndOf="@+id/clear_text_button"
            app:layout_constraintStart_toStartOf="@+id/country_flag"
            app:layout_constraintTop_toBottomOf="@+id/report_input_number" />


        <TextView
            android:id="@+id/error_message"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:layout_marginTop="8dp"
            android:paddingBottom="@dimen/activity_vertical_margin"
            android:textColor="@color/emergency_button_color"
            app:layout_constraintEnd_toEndOf="@+id/textview_underline_number"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="@+id/textview_underline_number"
            app:layout_constraintTop_toBottomOf="@+id/textview_underline_number" />

    </android.support.constraint.ConstraintLayout>

</android.support.design.widget.CoordinatorLayout>

<Button
    android:id="@+id/save_button"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_margin="@dimen/activity_horizontal_margin"
    android:background="@drawable/report_next_button_background"
    android:enabled="false"
    android:text="@string/melden_input_volgende"
    android:textAllCaps="false"
    android:textColor="@color/inactive_text"
    android:textSize="@dimen/text_16sp"
    android:textStyle="bold" />

Desired result on smaller devices when there is not enough room to display the input fields + button under the expanded toolbar:


Use adjustpan. It will solve your issue.

android, When the keyboard is opened, the button is overlapping the input fields instead of collapsing the toolbar. I've tried adding android:fitsSystemWindows="true" to  I have the following layout in my android app but I have a problem with windowSoftInputMode="adjustResize" in the activity: The LinearLayout named "container" contains multiple EditTexts but when one of them has focus and the keyboard appears, the Activity does not resize and the EditText is hidden behind the keyboard.


You need to set on the CoordinatorLayout:

android:fitsSystemWindows="false"

This value is default true. In your Android Manifest you need to set the following for the Activity related:

windowSoftInputMode="adjustResize"

I found the solution to the question in this article: https://code.luasoftware.com/tutorials/android/move-layout-when-keyboard-shown/

I know it's been a while since someone wrote on this thread, but since I came along this as well, I wanted to share my results.

Coordinatorlayout adjustResize not collapsing toolbar - android, Meaning the screen should not have any color for status bar (i.e transparent), Problem Solved 3: Android Full Screen View + Translucent + ScrollView + AdjustResize + Keyboard to allow the user to use EditText efficiently keeping soft-keyboard open. Using windowTranslucentStatus with CollapsingToolbarLayout  The only way to focus EditText No 8 is to hide the keyboard, scroll down and click EditText No 8. You can scroll up without hiding the keyboard. If you set android:windowSoftInputMode="adjustResize", the top portion of the activity (Toolbar/Appbar) is maintained with EditText pushed to above the keyboard.


Currently I have a very hacky solution which is by far from optimal. I would gladly hear if anyone has a better solution. I figured out that the toolbar won't collapse since the view that is focussed, is already visible. So now i programmatically switch focus to the last item and back to the first item to collapse the toolbar.

    report_input_number.requestFocus()

    Handler().postDelayed( {
        report_input_name.requestFocus()
    }, 350)

I'm using the following layout:

<LinearLayout 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:gravity="center|bottom"
android:orientation="vertical">

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">

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

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/nested_scroll_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="16dp">

            <TextView
                android:id="@+id/report_input_name_hint"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginEnd="16dp"
                android:layout_marginStart="16dp"
                android:text="@string/report_phonenumber_name_hint"
                android:textColor="@color/light_grey"
                android:visibility="invisible"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <EditText
                android:id="@+id/report_input_name"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginStart="16dp"
                android:layout_marginTop="8dp"
                android:background="@android:color/transparent"
                android:hint="@string/report_phonenumber_name_hint"
                android:inputType="textPersonName"
                android:maxLength="120"
                android:textColorHint="@color/text_color_hint"
                android:textSize="@dimen/text_18sp"
                app:layout_constraintEnd_toStartOf="@+id/clear_text_button_name"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/report_input_name_hint" />

            <ImageView
                android:id="@+id/clear_text_button_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="8dp"
                android:contentDescription="@string/accessibility_image_description_clear_text_button"
                android:padding="@dimen/linespace_10dp"
                android:visibility="invisible"
                app:layout_constraintBottom_toBottomOf="@+id/report_input_name"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="@+id/report_input_name"
                app:srcCompat="@drawable/icn_pro_cross" />

            <View
                android:id="@+id/textview_underline_name"
                android:layout_width="0dp"
                android:layout_height="1dp"
                android:layout_marginEnd="8dp"
                android:layout_marginTop="8dp"
                android:background="@color/light_grey"
                app:layout_constraintEnd_toEndOf="@+id/clear_text_button_name"
                app:layout_constraintStart_toStartOf="@+id/report_input_name"
                app:layout_constraintTop_toBottomOf="@+id/report_input_name" />

            <TextView
                android:id="@+id/report_input_number_hint"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginEnd="16dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="16dp"
                android:text="@string/telefoonnummer"
                android:textColor="@color/light_grey"
                android:visibility="invisible"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/textview_underline_name" />

            <ImageView
                android:id="@+id/country_flag"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="16dp"
                android:adjustViewBounds="false"
                android:contentDescription="@string/accessibility_image_description_country_flag"
                android:padding="@dimen/linespace_10dp"
                android:src="@drawable/flag_netherlands"
                app:layout_constraintBottom_toBottomOf="@+id/report_input_number"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="@+id/report_input_number" />

            <ImageView
                android:id="@+id/dropdown_arrow"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:rotation="90"
                android:src="@drawable/dropdown_arrow"
                app:layout_constraintBottom_toBottomOf="@+id/country_flag"
                app:layout_constraintStart_toEndOf="@+id/country_flag"
                app:layout_constraintTop_toTopOf="@+id/country_flag"
                tools:ignore="ContentDescription" />

            <TextView
                android:id="@+id/country_code"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="4dp"
                android:text="@string/report_phone_dutch_country_code"
                android:textColor="@color/dark_text"
                android:textSize="@dimen/text_18sp"
                app:layout_constraintBottom_toBottomOf="@+id/report_input_number"
                app:layout_constraintStart_toEndOf="@+id/dropdown_arrow"
                app:layout_constraintTop_toTopOf="@+id/report_input_number" />

            <EditText
                android:id="@+id/report_input_number"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginStart="8dp"
                android:layout_marginTop="8dp"
                android:background="@android:color/transparent"
                android:focusable="true"
                android:hint="@string/report_phone_text_hint"
                android:inputType="number"
                android:maxLength="13"
                android:textColorHint="@color/text_color_hint"
                android:textSize="@dimen/text_18sp"
                app:layout_constraintEnd_toStartOf="@+id/clear_text_button"
                app:layout_constraintStart_toEndOf="@+id/country_code"
                app:layout_constraintTop_toBottomOf="@+id/report_input_number_hint" />

            <ImageView
                android:id="@+id/clear_text_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="8dp"
                android:contentDescription="@string/accessibility_image_description_clear_text_button"
                android:padding="@dimen/linespace_10dp"
                android:visibility="invisible"
                app:layout_constraintBottom_toBottomOf="@+id/report_input_number"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="@+id/report_input_number"
                app:srcCompat="@drawable/icn_pro_cross" />

            <View
                android:id="@+id/textview_underline_number"
                android:layout_width="0dp"
                android:layout_height="1dp"
                android:layout_marginEnd="8dp"
                android:layout_marginTop="8dp"
                android:background="@color/light_grey"
                app:layout_constraintEnd_toEndOf="@+id/clear_text_button"
                app:layout_constraintStart_toStartOf="@+id/country_flag"
                app:layout_constraintTop_toBottomOf="@+id/report_input_number" />


            <TextView
                android:id="@+id/error_message"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="8dp"
                android:layout_marginTop="8dp"
                android:paddingBottom="@dimen/activity_vertical_margin"
                android:textColor="@color/emergency_button_color"
                app:layout_constraintEnd_toEndOf="@+id/textview_underline_number"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintStart_toStartOf="@+id/textview_underline_number"
                app:layout_constraintTop_toBottomOf="@+id/textview_underline_number" />

        </android.support.constraint.ConstraintLayout>

    </android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>

<Button
    android:id="@+id/save_button"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="@dimen/activity_horizontal_margin"
    android:layout_marginEnd="@dimen/activity_horizontal_margin"
    android:layout_marginStart="@dimen/activity_horizontal_margin"
    android:layout_marginTop="@dimen/activity_horizontal_margin"
    android:layout_weight="0"
    android:background="@drawable/report_next_button_background"
    android:enabled="false"
    android:text="@string/melden_input_volgende"
    android:textAllCaps="false"
    android:textColor="@color/inactive_text"
    android:textSize="@dimen/text_16sp"
    android:textStyle="bold" />
</LinearLayout>

Problem Solved 3: Android Full Screen View + Translucent + , I need to set adjustResize to enable scrolling to the bottom of the screen while the keyboard is open. However, I do not want the BottomNavigationView to be visible. (the material design way) would be using CoordinatorLayout and scrolling behavior (same as you might have seen CollapsingToolBar ). This feature is not available right now. Please try again later.


How to hide the BottomNavigationView below keyboard with , adjustPan : The activity's main window is not resized to make room for the soft keyboard. If you set android:windowSoftInputMode="adjustResize" , the top portion of the It is because CoordinatorLayout android:fitsSystemWindows="​true" . CollapsingToolbarLayout android:id="@+id/toolbar_layout"  A NestedScrollView with multiple EditText fields inside of it which actually pushes the CollapsingToolbar to collapse when you try to enter something in the EditText The actual problem The problem was that when you tap on one of the EditText fields and the keyboard opens, then you cannot scroll down to the last EditText that is visible so you can enter some text into it.


Move Layout When Keyboard Shown (Avoid Keyboard Overlap , up when keyboard opens. Why is adjust resize not working android? Add offset for auto scroll when softKeyboard is open (adjustPan) Android Keyboard not pushing layout up How to fix the toolbar to the top in activity with the 'adjustpan' option? What can Coordinatorlayout adjustresize not working · Adjust Pan not  How to create a 3D Terrain with Google Maps and height maps in Photoshop - 3D Map Generator Terrain - Duration: 20:32. Orange Box Ceo 6,619,433 views


Questions for tag adjustpan, I found out that the adjustResize function is not working as soon as If you have a long input and open the keyboard the view will add the space at Drawer showing navigation bar's shadow, even when in fullscreen #2177. To add a collapsing toolbar to your layout, place the CollapsingToolbarLayout inside an AppBarLayout. Then, add a Toolbar and any other views as a child to the CollapsingToolbarLayout. Make sure that the entire view structure is inside a CoordinatorLayout to take advantage of CollapsingToolbarLayout ’s