title: How to set my toolbar fixed while scrolling android
body: <p>I am currently working in e-commerce android app, i need to fix the toolbar while scrolling.</p>
  
  <p>As i attached the screenshot below. while scrolling the action bar need to be fixed and the body content scroll behind the toolbar </p>
  
  <p><a href="https://i.stack.imgur.com/jsfyz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jsfyz.png" alt="enter image description here"></a></p>
  
  <p>Here is the layout xml:</p>
  
  <p></p>
  
  <pre><code>&lt;LinearLayout
      android:id="@+id/container_toolbar"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"&gt;
  
      &lt;include
          android:id="@+id/toolbar_reg"
          layout="@layout/app_bar" /&gt;
  &lt;/LinearLayout&gt;
  
  &lt;ScrollView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:elevation="3dp"&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_marginTop="?android:attr/actionBarSize"
          android:background="#ffffff"
          android:orientation="vertical"&gt;
  
          &lt;ImageView
              android:layout_width="match_parent"
              android:layout_height="150dp"
              android:layout_marginTop="15dp"
              android:src="@drawable/logo" /&gt;
  
  
          &lt;android.support.design.widget.TextInputLayout
              android:id="@+id/input_layout_name"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="5dp"
              android:layout_marginLeft="15dp"
              android:layout_marginRight="15dp"
              android:layout_marginTop="5dp"&gt;
  
              &lt;EditText
                  android:id="@+id/input_name"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
  
                  android:hint="@string/reg_name"
                  android:singleLine="true" /&gt;
          &lt;/android.support.design.widget.TextInputLayout&gt;
  
          &lt;android.support.design.widget.TextInputLayout
              android:id="@+id/input_layout_email"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="5dp"
              android:layout_marginLeft="15dp"
              android:layout_marginRight="15dp"
              android:layout_marginTop="5dp"&gt;
  
              &lt;EditText
                  android:id="@+id/input_email"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
  
                  android:hint="@string/reg_email"
                  android:inputType="textEmailAddress" /&gt;
          &lt;/android.support.design.widget.TextInputLayout&gt;
  
          &lt;android.support.design.widget.TextInputLayout
              android:id="@+id/input_layout_password"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="5dp"
              android:layout_marginLeft="15dp"
              android:layout_marginRight="15dp"
              android:layout_marginTop="5dp"&gt;
  
              &lt;EditText
                  android:id="@+id/input_password"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
  
                  android:hint="@string/reg_password"
                  android:inputType="textPassword" /&gt;
          &lt;/android.support.design.widget.TextInputLayout&gt;
  
          &lt;android.support.design.widget.TextInputLayout
              android:id="@+id/input_layout_cpassword"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="5dp"
              android:layout_marginLeft="15dp"
              android:layout_marginRight="15dp"
              android:layout_marginTop="5dp"&gt;
  
              &lt;EditText
                  android:id="@+id/input_cpassword"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
  
                  android:hint="Confirm Password"
                  android:inputType="textPassword" /&gt;
          &lt;/android.support.design.widget.TextInputLayout&gt;
  
          &lt;android.support.design.widget.TextInputLayout
              android:id="@+id/input_layout_mobile"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="5dp"
              android:layout_marginLeft="15dp"
              android:layout_marginRight="15dp"
              android:layout_marginTop="5dp"&gt;
  
              &lt;EditText
                  android:id="@+id/input_mobile"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
  
                  android:hint="Mobile No"
                  android:inputType="number" /&gt;
          &lt;/android.support.design.widget.TextInputLayout&gt;
  
          &lt;android.support.design.widget.TextInputLayout
              android:id="@+id/input_layout_dob"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="5dp"
              android:layout_marginLeft="15dp"
              android:layout_marginRight="15dp"
              android:layout_marginTop="5dp"&gt;
  
              &lt;EditText
                  android:id="@+id/input_dob"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
  
                  android:hint="Date of Birth" /&gt;
          &lt;/android.support.design.widget.TextInputLayout&gt;
  
          &lt;android.support.design.widget.TextInputLayout
              android:id="@+id/input_layout_address"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="5dp"
              android:layout_marginLeft="15dp"
              android:layout_marginRight="15dp"
              android:layout_marginTop="5dp"&gt;
  
              &lt;EditText
                  android:id="@+id/input_address"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:hint="Permanent Address" /&gt;
          &lt;/android.support.design.widget.TextInputLayout&gt;
  
          &lt;Button
              android:id="@+id/btn_signup"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_marginLeft="15dp"
              android:layout_marginRight="15dp"
              android:layout_marginTop="25dp"
              android:background="@color/colorPrimary"
              android:text="@string/btn_sign_up"
              android:textColor="@android:color/white" /&gt;
  
          &lt;TextView
              android:id="@+id/link_login"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="150dp"
              android:layout_marginTop="15dp"
              android:gravity="center"
              android:text="@string/req_login"
              android:textSize="16dp" /&gt;
  
      &lt;/LinearLayout&gt;
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p></p>