title: CollapsingToolbarLayout ignores exitUntilCollapsed flag and scrolls out of view when soft keyboard is visible
body: <p>I am attempting to set up a text processor activity with a scrollable EditText and a partially collapsible toolbar.</p>
  <p>Currently I am using a CoordinatorLayout with a Toolbarwidget nested in a CollapsingToolbarLayout nested in an AppBarLayout, and a NestedScrollView containing an EditText. The CollapsingToolbarLayout has app:layout_scrollFlags set to &quot;scroll|exitUntilCollapsed&quot;.</p>
  <p>The toolbar should collapse to it's minimum height as the user scrolls or enters text. Once the toolbar reaches it's minimum height it should stay pinned at the top of the screen.</p>
  <p>Scrolling works as expected when the keyboard is not visible. However, whether scrolling or typing, if the soft keyboard is visible the toolbar shrinks beyond it's minimum height and scrolls all the way out of view.</p>
  <p>Similar problems like the ones <a href="https://stackoverflow.com/questions/32649710/android-toolbar-moves-up-when-keyboard-appears">here</a> and <a href="https://stackoverflow.com/questions/34879097/open-on-screen-keyboard-causes-toolbar-to-scroll-out-of-sight">here</a>
  seem to be solved using adjustPan, adjustResize, and/or fitsSystemWindow.</p>
  <p>However I have set fitsSystemWindow: true and I have tried to no avail setting android:windowSoftInputMode=&quot;adjustPan&quot; as well as android:windowSoftInputMode=&quot;adjustResize&quot; in the manifest. With adjustResize the toolbar behaves correctly but the cursor moves behind the keyboard so you can't see what your typing.</p>
  <p>Here is my layout:</p>
  <pre><code>&lt;androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:fitsSystemWindows=&quot;true&quot;
      tools:context=&quot;.ui.wordprocessor.ScrollingEditTextActivity&quot;&gt;
  
      &lt;com.google.android.material.appbar.AppBarLayout
          android:id=&quot;@+id/app_bar&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;@dimen/app_bar_height&quot;
          android:fitsSystemWindows=&quot;true&quot;
          android:theme=&quot;@style/Theme.AuthorGenie3.AppBarOverlay&quot;&gt;
  
          &lt;com.google.android.material.appbar.CollapsingToolbarLayout
              android:id=&quot;@+id/toolbar_layout&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;
              android:fitsSystemWindows=&quot;true&quot;
              app:contentScrim=&quot;?attr/colorPrimary&quot;
              app:layout_scrollFlags=&quot;scroll|exitUntilCollapsed&quot;
              app:toolbarId=&quot;@+id/toolbar&quot;&gt;
  
              &lt;androidx.appcompat.widget.Toolbar
                  android:id=&quot;@+id/toolbar&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;?attr/actionBarSize&quot;
                  app:layout_collapseMode=&quot;pin&quot;
                  app:popupTheme=&quot;@style/Theme.AuthorGenie3.PopupOverlay&quot;&gt;
              &lt;/androidx.appcompat.widget.Toolbar&gt;
  
          &lt;/com.google.android.material.appbar.CollapsingToolbarLayout&gt;
      &lt;/com.google.android.material.appbar.AppBarLayout&gt;
      
  
  
      &lt;include layout=&quot;@layout/content_scrolling&quot; /&gt;
  
  &lt;/androidx.coordinatorlayout.widget.CoordinatorLayout&gt;
  </code></pre>
  <p>Any suggestions would be much appreciated!</p>