Scrollview not working in this XML file in Android
<p>This doesn't works for my login when I click on edittext for entering password or username, I want to get items scrolled when virtual/ soft keyboard is open.</p>

<p>I have also tried to put Scrollview as parent tag and then LinearLayout tag but the contents starts from top only, while I want the contents in the center because there is my background with login logo.    </p>

<pre><code>&lt;LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:background="@drawable/login"
        android:gravity="center"&gt;

        &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent"&gt;
            &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"&gt;

                &lt;LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:gravity="center"&gt;

                    &lt;EditText
                        android:id="@+id/edt_email"
                        android:layout_width="match_parent"
                        android:layout_height="50dp"
                        android:hint="Email Address"
                        android:gravity="center|left"
                        android:textSize="16sp"
                        android:textColorHint="#c3c3c3"
                        android:singleLine="true"
                        android:background="@drawable/black_underline"
                        android:inputType="textEmailAddress"
                        android:paddingLeft="5dp"
                        android:textColor="#000"
                        /&gt;
                    &lt;EditText
                        android:id="@+id/edt_phone"
                        android:layout_width="match_parent"
                        android:layout_height="50dp"
                        android:hint="Phone Number"
                        android:gravity="center|left"
                        android:textSize="16sp"
                        android:textColorHint="#c3c3c3"
                        android:singleLine="true"
                        android:maxLength="10"
                        android:background="@drawable/black_underline"
                        android:inputType="number"
                        android:paddingLeft="5dp"
                        android:textColor="#000"

                        /&gt;

                    &lt;Button
                        android:id="@+id/btn_otp"
                        android:layout_width="match_parent"
                        android:layout_height="50dp"
                        android:layout_marginTop="20dp"
                        android:background="#449284"
                        android:text="Generate OTP Password"
                        android:textAllCaps="false"
                        android:textSize="20sp"
                        android:textColor="#fff"
                        android:gravity="center"
                        /&gt;

                    &lt;EditText
                        android:id="@+id/edt_otp"
                        android:layout_width="match_parent"
                        android:layout_height="50dp"
                        android:hint="OTP Password"
                        android:background="@drawable/black_underline"
                        android:gravity="center|left"
                        android:textSize="16sp"
                        android:textColorHint="#c3c3c3"
                        android:visibility="gone"
                        android:singleLine="true"
                        android:inputType="number"
                        android:layout_marginTop="20dp"
                        android:paddingLeft="5dp"
                        android:textColor="#000"

                        /&gt;
                    &lt;Button
                        android:id="@+id/btn_submit"
                        android:layout_width="match_parent"
                        android:layout_height="50dp"
                        android:layout_marginTop="20dp"
                        android:background="#449284"
                        android:text="Submit"
                        android:textSize="20sp"
                        android:textAllCaps="false"
                        android:visibility="gone"
                        android:textColor="#fff"
                        android:gravity="center"
                        /&gt;


                &lt;/LinearLayout&gt;

            &lt;/RelativeLayout&gt;
        &lt;/ScrollView&gt;
    &lt;/LinearLayout&gt;
</code></pre>