title: Make soft keyboard scroll view rather than resize it
body: <p>I am trying to emulate an iOS-like keyboard for my Android app. Simply put, the contents of my activity should scroll behind the keyboard <em>without resizing the spacing</em> (which is what <code>android:windowSoftInputMode="stateHidden|adjustResize"</code> does).</p>
  
  <p>I can achieve a close scroll behavior by making my parent layout a ScrollView (as suggested in <a href="https://stackoverflow.com/q/35108444/5748408">Make soft keyboard behave like IOS in Android</a>), but doing so <em>also</em> scrolls my custom action bar (which is an included <code>android.support.v7.widget.Toolbar</code>). Either I am not implementing a custom action bar correctly (so it is <em>always</em> at the top of the screen, ignoring scrolling), or there is some trick to get the soft keyboard to only scroll a resize (and scroll) a specific element to make room for itself.</p>
  
  <p>Hopefully this simple picture illustrates what I'm trying to achieve. In the screen on the right, the actionbar is left untouched and the main content spacin remains the same and the view is scrollable.</p>
  
  <p><a href="https://i.stack.imgur.com/IotDq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IotDq.png" alt="My desired keyboard scroll behavior"></a></p>
  
  <p>This is my custom actionbar layout that I include in my activity.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/actionbar"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:background="@color/primaryRed"
      android:elevation="4dp"
      android:orientation="vertical"&gt;
  
      &lt;RelativeLayout
          android:id="@+id/home"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:orientation="horizontal"&gt;
  
          &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="48dp"
              android:layout_alignParentStart="true"
              android:layout_alignParentTop="true"
              android:layout_gravity="center_vertical"
              android:layout_marginStart="-7dp"
              android:contentDescription="@string/back"
              android:scaleType="centerInside"
              android:src="@drawable/ic_up_unpadded" /&gt;
  
          &lt;TextView
              android:id="@+id/hint"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentStart="true"
              android:layout_centerVertical="true"
              android:layout_marginStart="20dp"
              android:text="@string/back"
              android:textColor="@android:color/white"
              android:textSize="20sp" /&gt;
  
      &lt;/RelativeLayout&gt;
  
      &lt;TextView
          android:id="@+id/title"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center"
          android:text="@string/theGlassFiles"
          android:textAllCaps="true"
          android:textColor="@android:color/white"
          android:textSize="22sp" /&gt;
  
  &lt;/android.support.v7.widget.Toolbar&gt;
  </code></pre>
  
  <p>The current view experiment layout is below. I've tried many things, none of which work. The one below is my latest test, which also does not achieve what I am try to get to.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ScrollView 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:fillViewport="true"
      android:fitsSystemWindows="true"
      tools:context="JoinActivity"&gt;
  
      &lt;android.support.constraint.ConstraintLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="center"&gt;
  
          &lt;include
              layout="@layout/actionbar"
              android:layout_width="match_parent"
              android:layout_height="wrap_content" /&gt;
  
          &lt;TextView
              android:id="@+id/message"
              android:layout_width="362dp"
              android:layout_height="wrap_content"
              android:layout_marginTop="76dp"
              android:gravity="center"
              android:lineSpacingExtra="8sp"
              android:text="@string/joinMessage"
              android:textColor="@color/primaryBlue"
              android:textSize="20sp"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintHorizontal_bias="0.489"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toTopOf="parent" /&gt;
  
          &lt;LinearLayout
              android:id="@+id/form"
              android:layout_width="362dp"
              android:layout_height="wrap_content"
              android:focusableInTouchMode="true"
              android:orientation="vertical"
              android:paddingBottom="20dp"
              android:paddingTop="20dp"
              app:layout_constraintBottom_toBottomOf="parent"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintHorizontal_bias="0.489"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toBottomOf="@+id/message"
              app:layout_constraintVertical_bias="0.176"&gt;
  
              &lt;EditText
                  android:id="@+id/firstName"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:ems="10"
                  android:hint="@string/firstNameHint"
                  android:imeOptions="actionDone"
                  android:inputType="textPersonName" /&gt;
  
              &lt;EditText
                  android:id="@+id/middleName"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="15dp"
                  android:ems="10"
                  android:hint="@string/middleNameHint"
                  android:imeOptions="actionDone"
                  android:inputType="textPersonName" /&gt;
  
              &lt;EditText
                  android:id="@+id/lastName"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="15dp"
                  android:ems="10"
                  android:hint="@string/lastNameHint"
                  android:imeOptions="actionDone"
                  android:inputType="textPersonName" /&gt;
  
              &lt;EditText
                  android:id="@+id/town"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="15dp"
                  android:ems="10"
                  android:hint="@string/townHint"
                  android:imeOptions="actionDone"
                  android:inputType="textPersonName" /&gt;
  
              &lt;EditText
                  android:id="@+id/password"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="15dp"
                  android:ems="10"
                  android:hint="@string/passwordHint"
                  android:imeOptions="actionDone"
                  android:inputType="textPersonName" /&gt;
  
              &lt;EditText
                  android:id="@+id/confirmPassword"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="15dp"
                  android:ems="10"
                  android:hint="@string/confirmPasswordHint"
                  android:imeOptions="actionDone"
                  android:inputType="textPersonName" /&gt;
  
              &lt;Button
                  android:id="@+id/joinButton"
                  android:layout_width="match_parent"
                  android:layout_height="49dp"
                  android:layout_marginTop="25dp"
                  android:background="@color/primaryRed"
                  android:text="@string/join"
                  android:textAllCaps="false"
                  android:textColor="@android:color/white"
                  android:textSize="22sp" /&gt;
  
          &lt;/LinearLayout&gt;
      &lt;/android.support.constraint.ConstraintLayout&gt;
  
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>Swapping around the parent/children layouts, I achieve something <em>really</em> close to what I'm aiming for. The actionbar always is on top, and the keyboard only resizes the scroll view. <strong>However</strong>, when I scroll I cannot scroll above the first <code>EditText</code> element. Using the picture, I can only scroll up to the first input, and cannot continue to scroll up and see the green icon. Using my actual XML layout, I cannot scroll to see the <code>TextView</code> component. Here is the updated layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;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"
      tools:context="JoinActivity"&gt;
  
      &lt;include
          layout="@layout/actionbar"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" /&gt;
  
      &lt;ScrollView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:fillViewport="true"
          android:layout_below="@id/actionbar"&gt;
  
          &lt;android.support.constraint.ConstraintLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="center"&gt;
  
              &lt;TextView
                  android:id="@+id/message"
                  android:layout_width="362dp"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="32dp"
                  android:gravity="center"
                  android:lineSpacingExtra="8sp"
                  android:text="@string/joinMessage"
                  android:textColor="@color/primaryBlue"
                  android:textSize="20sp"
                  app:layout_constraintEnd_toEndOf="parent"
                  app:layout_constraintHorizontal_bias="0.489"
                  app:layout_constraintStart_toStartOf="parent"
                  app:layout_constraintTop_toTopOf="parent" /&gt;
  
              &lt;LinearLayout
                  android:id="@+id/form"
                  android:layout_width="362dp"
                  android:layout_height="wrap_content"
                  android:focusableInTouchMode="true"
                  android:orientation="vertical"
                  android:paddingBottom="20dp"
                  android:paddingTop="20dp"
                  app:layout_constraintBottom_toBottomOf="parent"
                  app:layout_constraintEnd_toEndOf="parent"
                  app:layout_constraintHorizontal_bias="0.489"
                  app:layout_constraintStart_toStartOf="parent"
                  app:layout_constraintTop_toBottomOf="@+id/message"
                  app:layout_constraintVertical_bias="0.464"&gt;
  
                  &lt;EditText
                      android:id="@+id/firstName"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:ems="10"
                      android:hint="@string/firstNameHint"
                      android:imeOptions="actionDone"
                      android:inputType="textPersonName" /&gt;
  
                  &lt;EditText
                      android:id="@+id/middleName"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_marginTop="15dp"
                      android:ems="10"
                      android:hint="@string/middleNameHint"
                      android:imeOptions="actionDone"
                      android:inputType="textPersonName" /&gt;
  
                  &lt;EditText
                      android:id="@+id/lastName"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_marginTop="15dp"
                      android:ems="10"
                      android:hint="@string/lastNameHint"
                      android:inputType="textPersonName" /&gt;
  
                  &lt;EditText
                      android:id="@+id/town"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_marginTop="15dp"
                      android:ems="10"
                      android:hint="@string/townHint"
                      android:inputType="textPersonName" /&gt;
  
                  &lt;EditText
                      android:id="@+id/password"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_marginTop="15dp"
                      android:ems="10"
                      android:hint="@string/passwordHint"
                      android:inputType="textPersonName" /&gt;
  
                  &lt;EditText
                      android:id="@+id/confirmPassword"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_marginTop="15dp"
                      android:ems="10"
                      android:hint="@string/confirmPasswordHint"
                      android:inputType="textPersonName" /&gt;
  
                  &lt;Button
                      android:id="@+id/joinButton"
                      android:layout_width="match_parent"
                      android:layout_height="49dp"
                      android:layout_marginTop="25dp"
                      android:background="@color/primaryRed"
                      android:text="@string/join"
                      android:textAllCaps="false"
                      android:textColor="@android:color/white"
                      android:textSize="22sp" /&gt;
  
              &lt;/LinearLayout&gt;
          &lt;/android.support.constraint.ConstraintLayout&gt;
      &lt;/ScrollView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>