Android make entire screen scroll to certain point when keyboard shows
<p>I have an android app with a login screen (screenshot 1) and the login screen has 3 main views: inputs for username and password and a login button. I want all three of them to be visible when keyboard is shown (scroll entire screen/view upwards) the rest can be moved out of screen or blocked by keyboard.</p>

<p>I have read most of the similar stack overflow posts about this, but most of them say to use <code>android:windowSoftInputMode="adjustResize"</code>, <code>android:windowSoftInputMode="adjustPan"</code> or both and i have tried both of them and some combinations with <code>stateVisible</code>, but none work. The closest to the wanted result i got, was by using <code>adjustPan</code> (screenshot 2).</p>

<p>Layout for login screen:</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"
    android:id="@+id/login_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/primary"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"&gt;
    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="center_horizontal"&gt;
    &lt;!--Language select--&gt;
        &lt;include
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            layout="@layout/lang_select" /&gt;
    &lt;!--Text: "Sign in"--&gt;
        &lt;TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Sign in"
            android:textAlignment="center"
            android:textAllCaps="true"
            android:padding="24dp"
            android:textStyle="bold"
            android:textColor="@android:color/white"
            android:textSize="20sp" /&gt;
    &lt;!--google+ register button--&gt;
        &lt;LinearLayout
            android:id="@+id/btn_google_login"
            android:layout_width="match_parent"
            android:layout_height="36dp"
            android:layout_gravity="right"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp"
            style="@style/MyTheme.Button.Red"&gt;
            &lt;ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_google_plus"
                android:layout_marginRight="8dp" /&gt;
            &lt;TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@android:color/white"
                android:text="Sign in with Google+"
                android:textSize="16dp" /&gt;
        &lt;/LinearLayout&gt;
    &lt;!--Divider ("OR")--&gt;
        &lt;include
            layout="@layout/divider" /&gt;
    &lt;!--Form--&gt;
        &lt;LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:descendantFocusability="beforeDescendants"
            android:focusableInTouchMode="true"&gt;
            &lt;android.support.design.widget.TextInputLayout
                android:id="@+id/login_username_input"
                android:layout_width="match_parent"
                android:layout_height="84dp"
                android:padding="0dp"
                style="@style/MyTheme.TextInputLayout"
                app:hintTextAppearance="@style/MyTheme.TextInputLayout.Activated"&gt;
                &lt;EditText
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/username"
                    android:textColor="@android:color/white"
                    android:inputType="text"
                    android:imeOptions="actionNext" /&gt;
            &lt;/android.support.design.widget.TextInputLayout&gt;
            &lt;android.support.design.widget.TextInputLayout
                android:id="@+id/login_password_input"
                android:layout_width="match_parent"
                android:layout_height="84dp"
                android:padding="0dp"
                style="@style/MyTheme.TextInputLayout"
                app:hintTextAppearance="@style/MyTheme.TextInputLayout.Activated"&gt;
                &lt;EditText
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/password"
                    android:inputType="textPassword"
                    android:textColor="@android:color/white" /&gt;
            &lt;/android.support.design.widget.TextInputLayout&gt;
        &lt;!--Login button--&gt;
            &lt;LinearLayout
                android:id="@+id/btn_login"
                android:layout_width="match_parent"
                android:layout_height="36dp"
                android:layout_gravity="right"
                style="@style/MyTheme.Button.Empty"&gt;
                &lt;ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_user_plus"
                    android:layout_marginRight="8dp" /&gt;
                &lt;TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textColor="@android:color/white"
                    android:text="Sign in"
                    android:textSize="16sp" /&gt;
            &lt;/LinearLayout&gt;
        &lt;!--"Forgot password"--&gt;
            &lt;TextView
                android:id="@+id/btn_forgot_password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="@android:color/white"
                android:textSize="14sp"
                android:text="@string/forgot_password"
                android:gravity="center_horizontal"
                android:padding="8dp"
                android:clickable="true"
                android:background="?android:attr/selectableItemBackground" /&gt;
        &lt;/LinearLayout&gt;
    &lt;/LinearLayout&gt;
&lt;!--"Register a new account"--&gt;
    &lt;TextView
        android:id="@+id/btn_register_here"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="16dp"
        android:clickable="true"
        android:background="?android:attr/selectableItemBackground"
        android:padding="8dp"
        android:textColor="@android:color/white"
        android:textSize="14sp"
        android:text="@string/register_here" /&gt;
&lt;!--For using snackbar--&gt;
    &lt;android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:id="@+id/login_coord_layout" /&gt;
&lt;/RelativeLayout&gt;
</code></pre>

<p><strong>Screenshot 1:</strong>
<a href="https://i.stack.imgur.com/xzWhL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xzWhL.png" alt="Login screen"></a></p>

<p><strong>Screenshot 2:</strong> Login screen with keyboard showing with <code>adjustPan</code>. The whole screen has moved up a bit so the password input would be above keyboard. I want to move the whole view up even more so that the login button would be visible no matter which text input field has focus.
<a href="https://i.stack.imgur.com/bFw6K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bFw6K.png" alt="Login screen with keyboard"></a></p>