AppBarLayout won't scroll to focused EditText

Viewed 218

I have a layout where EditText is inside AppBarLayout. If user clicks on EditText, keyboard is shown but the layout won't scroll to make EditText visible. Normally, if EditText would be in ScrollView, it would scroll so that EditText is above the keyboard. It doesn't happen in this case.

<androidx.coordinatorlayout.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_scrollFlags="scroll" />
    </com.google.android.material.appbar.AppBarLayout>

    <androidx.recyclerview.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

Is there a way to scroll the layout manually so that EditText won't hide under the keyboard? Also, if EditText is multiline, how to scroll to where cursor is, not where the view top is (when EditText size is wrap content it will change it height if multiline, and normally view would scroll so that cursor is always visible, which is not the case here).

Edit:

Input mode is set to android:windowSoftInputMode="adjustResize" and I cannot change it to adjustPan because some parts of the layout are obscured when keyboard is present (e.g. activity's toolbar)

0 Answers
Related