title: How to affix a LinearLayout at the bottom of a screen in coordinator layout?
body: <p>I have a situation where linearlayout doesn't stay fixed at the bottom of the co-ordinatorlayout but moves with respect to the scrollview contents above. </p>
  
  <p>I have tried all solutions on StackOverflow but still no luck (ex:<a href="https://stackoverflow.com/questions/46354035/keep-linearlayout-at-the-bottom-of-screen">Keep LinearLayout at the bottom of screen</a> and even tried relativelayout but no luck: <a href="https://stackoverflow.com/questions/14349716/make-a-relativelayout-at-the-bottom-of-a-scrollview">Make a RelativeLayout at the bottom of a Scrollview</a> ). I am not sure what could be causing this, for the linear/relativelayout to move with respect to the scrollview, but if anyone else can figure out what I am doing wrong or missing, that'll be a great help! 
  Thanks in advance! Here's my XML code below: (open to sharing any other relevant java code if that helps )</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.design.widget.CoordinatorLayout 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:background="@color/white"
      android:clickable="false"
      android:fitsSystemWindows="true"
      android:fillViewport="true"
      android:id="@+id/cl_root_view"
      &gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:id="@+id/main_register_container"
          android:layout_marginBottom="60dp"
          android:background="@color/white"
          android:orientation="vertical"&gt;
  
          &lt;LinearLayout
              android:id="@+id/activity_register_guest"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical"&gt;
  
              &lt;android.support.design.widget.AppBarLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  app:elevation="0dp"&gt;
  
  
                  &lt;android.support.v7.widget.Toolbar
                      android:id="@+id/toolbar"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:background="@color/white"
                      app:subtitleTextColor="@color/white"
                      app:titleTextAppearance="@style/Toolbar.TitleText"
                      app:titleTextColor="@color/white"&gt;
  
  
                      &lt;!--&lt;TextView
                          android:id="@+id/nav_back_btn"
                          style="@style/Body1RegLeftBlack"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginStart="@dimen/activity_horizontal_margin"
                          android:layout_marginTop="20dp"
                          android:background="@drawable/ic_backarrow"
                          android:gravity="center_horizontal" /&gt;--&gt;
  
                      &lt;TextView
                          android:id="@+id/register_guest_main_title"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginStart="18dp"
                          android:layout_marginTop="15dp"
                          android:layout_gravity="center"
                          android:letterSpacing="0.01"
                          android:textAllCaps="true"
                          android:text="@string/register_guest"
                          android:textAppearance="@style/TextAppearance.Text.Roboto.Medium"
                          android:textColor="#de000000"
                          android:textSize="17sp"
                          android:textStyle="normal"
  
                          /&gt;
  
                  &lt;/android.support.v7.widget.Toolbar&gt;
  
  
              &lt;/android.support.design.widget.AppBarLayout&gt;
  
              &lt;ScrollView
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:fillViewport="true"
                  android:background="@color/white"
                  android:fitsSystemWindows="true"
                  android:layout_marginBottom="65dp"&gt;
  
                  &lt;RelativeLayout
                      android:id="@+id/register_visitor_container"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:background="@color/white"
                      android:clickable="false"
                      android:fillViewport="true"&gt;
  
                      &lt;LinearLayout
                          android:id="@+id/main_register_layout"
                          android:layout_width="match_parent"
                          android:layout_height="match_parent"
                          android:orientation="vertical"&gt;
  
                          &lt;RelativeLayout
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_marginTop="5dp"&gt;
  
                              &lt;TextView
                                  android:id="@+id/my_location"
                                  style="@style/Headline2LeftBlack"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_marginStart="@dimen/activity_horizontal_margin"
                                  android:textAppearance="@style/TextAppearance.Text.Chronicle"
                                  android:textSize="28sp"
                                  tools:text="@string/five_thirty_fifth_ave" /&gt;
  
                              &lt;TextView
                                  style="@style/Body1RegRightRed"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_alignBaseline="@+id/my_location"
                                  android:layout_alignParentEnd="true"
                                  android:layout_marginEnd="@dimen/activity_horizontal_margin"
                                  android:layout_toEndOf="@+id/my_location"
                                  android:text="@string/location_change"
                                  android:textAppearance="@style/TextAppearance.Text.Roboto.Regular"
                                  android:visibility="gone" /&gt;
                          &lt;/RelativeLayout&gt;
                          &lt;LinearLayout
                              android:layout_width="match_parent"
                              android:layout_height="28dp"
                              android:layout_marginTop="24dp"
                              android:gravity="center_vertical"
                              android:layout_marginBottom="8dp"
                              android:weightSum="2"&gt;
  
                              &lt;TextView
                                  android:id="@+id/select_date_and_time"
                                  android:layout_width="wrap_content"
                                  android:textSize="17sp"
                                  android:lineSpacingExtra="6sp"
                                  android:layout_height="wrap_content"
                                  android:layout_marginStart="16dp"
                                  android:textColor="@color/black"
                                  android:text="@string/select_date_and_time"
                                  android:textAppearance="@style/TextAppearance.Text.Roboto.Medium" /&gt;
  
                          &lt;/LinearLayout&gt;
                          &lt;View
                              android:layout_width="match_parent"
                              android:layout_height="1dp"
                              android:layout_marginStart="16dp"
                              android:layout_marginEnd="16dp"
                              android:background="@color/registerUserSeparatorColor" /&gt;
  
                          &lt;LinearLayout
                              android:layout_width="match_parent"
                              android:layout_height="48dp"
                              android:gravity="center_vertical"
                              android:weightSum="2"&gt;
  
                              &lt;TextView
                                  android:id="@+id/register_guest_start_date"
                                  style="@style/Body1RegLeftBlack"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_marginStart="16dp"
                                  android:layout_weight="1"
                                  android:text="@string/register_guest_start_date"
                                  android:textAppearance="@style/TextAppearance.Text.Roboto.Regular" /&gt;
  
                              &lt;TextView
                                  android:id="@+id/register_guest_start_time"
                                  style="@style/Body1RegRightBlack"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_marginEnd="16dp"
                                  android:layout_weight="1"
                                  android:text="@string/register_guest_start_time"
                                  android:textAppearance="@style/TextAppearance.Text.Roboto.Regular" /&gt;
                          &lt;/LinearLayout&gt;
  
                          &lt;View
                              android:layout_width="match_parent"
                              android:layout_height="1dp"
                              android:layout_marginStart="16dp"
                              android:layout_marginEnd="16dp"
                              android:background="@color/registerUserSeparatorColor" /&gt;
  
                          &lt;LinearLayout
                              android:layout_width="match_parent"
                              android:layout_height="48dp"
                              android:gravity="center_vertical"
                              android:weightSum="2"&gt;
  
                              &lt;TextView
                                  android:id="@+id/register_guest_end_date"
                                  style="@style/Body1RegLeftBlack"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_marginStart="16dp"
                                  android:layout_weight="1"
                                  android:text="@string/register_guest_end_date"
                                  android:textAppearance="@style/TextAppearance.Text.Roboto.Regular"
                                  android:visibility="invisible" /&gt;
  
                              &lt;TextView
                                  android:id="@+id/register_guest_end_time"
                                  style="@style/Body1RegRightBlack"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_marginEnd="16dp"
                                  android:layout_weight="1"
                                  android:text="@string/register_guest_end_time"
                                  android:textAppearance="@style/TextAppearance.Text.Roboto.Regular" /&gt;
                          &lt;/LinearLayout&gt;
  
                          &lt;View
                              android:layout_width="match_parent"
                              android:layout_height="1dp"
                              android:layout_marginStart="16dp"
                              android:layout_marginEnd="16dp"
                              android:background="@color/registerUserSeparatorColor" /&gt;
  
                          &lt;TextView
                              android:id="@+id/build_your_guest_list"
                              android:layout_width="wrap_content"
                              android:textSize="17sp"
                              android:layout_marginTop="42dp"
                              android:lineSpacingExtra="6sp"
                              android:layout_height="wrap_content"
                              android:layout_marginStart="16dp"
                              android:textColor="@color/black"
                              android:text="@string/build_your_guest_list"
                              android:paddingBottom="8dp"
                              android:textAppearance="@style/TextAppearance.Text.Roboto.Medium" /&gt;
  
  
  
                          &lt;View
                              android:layout_width="match_parent"
                              android:layout_height="1dp"
                              android:layout_marginStart="16dp"
                              android:layout_marginEnd="16dp"
                              android:background="@color/registerUserSeparatorColor" /&gt;
  
                          &lt;RelativeLayout
                              android:layout_width="wrap_content"
                              android:layout_height="44dp"
                              android:id="@+id/add_guest"
                              android:layout_marginTop="3dp"
                              android:layout_marginBottom="8dp"
                              &gt;
                          &lt;TextView
                              android:layout_width="wrap_content"
                              android:layout_height="44dp"
                              android:lineHeight="22sp"
                              android:drawablePadding="10dp"
                              android:drawableStart="@drawable/ic_add_24px"
                              android:drawableTint="@color/bluish"
                              android:layout_marginStart="17dp"
                              android:lineSpacingExtra="6sp"
                              android:textColor="@color/bluish"
                              android:gravity="center_vertical"
                              android:textAppearance="@style/TextAppearance.Text.Roboto.Medium"
                              android:text="@string/add_a_new_guest"
                              android:textSize="17sp" /&gt;
                          &lt;/RelativeLayout&gt;
                          &lt;View
                              android:layout_width="match_parent"
                              android:layout_height="1dp"
                              android:layout_marginStart="16dp"
                              android:layout_marginEnd="16dp"
                              android:background="@color/registerUserSeparatorColor"
                              /&gt;
  
                          &lt;RelativeLayout
                              android:layout_width="wrap_content"
                              android:layout_height="44dp"
                              android:id="@+id/search_guest"
                              android:layout_marginTop="3dp"
                              android:visibility="gone"
                              android:layout_marginBottom="8dp"
                              &gt;
                              &lt;TextView
                                  android:layout_width="wrap_content"
                                  android:layout_height="44dp"
                                  android:lineHeight="22sp"
                                  android:drawablePadding="10dp"
                                  android:drawableStart="@drawable/ic_search_24px"
                                  android:drawableTint="@color/bluish"
                                  android:layout_marginStart="17dp"
                                  android:lineSpacingExtra="6sp"
                                  android:textColor="@color/bluish"
                                  android:gravity="center_vertical"
                                  android:textAppearance="@style/TextAppearance.Text.Roboto.Medium"
                                  android:text="@string/search_past_guests"
                                  android:textSize="17sp" /&gt;
                          &lt;/RelativeLayout&gt;
                          &lt;View
                              android:layout_width="match_parent"
                              android:layout_height="1dp"
                              android:layout_marginStart="16dp"
                              android:layout_marginEnd="16dp"
                              android:visibility="gone"
                              android:id="@+id/search_guest_line"
                              android:background="@color/registerUserSeparatorColor"
                              /&gt;
  
                          &lt;android.support.v7.widget.RecyclerView
                              android:id="@+id/guest_item_list"
                              android:layout_width="match_parent"
                              android:layout_height="wrap_content"
                              android:divider="@null"
                              android:overScrollMode="never"
                              tools:listitem="@layout/item_guest" /&gt;
  
  
  
                          &lt;TextView
                              android:id="@+id/arrival_notifications"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_marginStart="16dp"
                              android:layout_marginTop="58dp"
                              android:letterSpacing="0.01"
                              android:lineSpacingExtra="4sp"
                              android:text="@string/arrival_notifications"
                              android:textAppearance="@style/TextAppearance.Text.Roboto.Medium"
                              android:textColor="@color/black"
                              android:textSize="20sp"
                              android:textStyle="normal"
                              android:visibility="invisible" /&gt;
  
                          &lt;RelativeLayout
                              android:id="@+id/text_message_container"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_marginStart="16dp"
                              android:visibility="gone"&gt;
  
                              &lt;TextView
                                  android:id="@+id/text_message"
                                  style="@style/Body1RegLeftBlack"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_marginTop="11dp"
                                  android:text="@string/text_message"
                                  android:textAppearance="@style/TextAppearance.Text.Roboto.Regular" /&gt;
  
                              &lt;TextView
                                  android:id="@+id/tap_phone_number_text"
                                  style="@style/Body2RegLeftGrey"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_below="@+id/text_message"
                                  android:layout_marginTop="2dp"
                                  android:text="@string/tap_to_add_a_phone_number"
                                  android:textAppearance="@style/TextAppearance.Text.Roboto.Regular" /&gt;
  
                              &lt;android.support.v7.widget.SwitchCompat
                                  android:id="@+id/text_message_switch"
                                  style="@style/Color1SwitchStyle"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_alignParentEnd="true"
                                  android:layout_centerVertical="true"
                                  android:layout_marginEnd="16dp" /&gt;
                          &lt;/RelativeLayout&gt;
  
                          &lt;View
                              android:layout_width="match_parent"
                              android:layout_height="1dp"
                              android:layout_marginStart="16dp"
                              android:layout_marginTop="11dp"
                              android:background="@color/settingsSeparatorLineColor"
                              android:visibility="gone" /&gt;
  
  
                      &lt;/LinearLayout&gt;
  
                     &lt;!-- &lt;TextView
                          android:id="@+id/submit_users_btn"
                          style="@style/LoginButton"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center|bottom"
                          android:layout_alignParentBottom="true"
                          android:layout_centerHorizontal="true"
                          android:paddingBottom="30dp"
                          android:letterSpacing="0.07"
                          android:lineSpacingExtra="0sp"
                          android:text="@string/submit_visitor_list"
                          android:textAppearance="@style/TextAppearance.Text.Roboto.Medium"
                          android:textSize="16sp"
                          android:textStyle="normal" /&gt; --&gt;
                  &lt;/RelativeLayout&gt;
              &lt;/ScrollView&gt;
  
          &lt;/LinearLayout&gt;
  
      &lt;/LinearLayout&gt;
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_alignParentStart="true"
          android:layout_alignParentEnd="true"
          android:layout_marginStart="16dp"
          android:layout_marginEnd="16dp"
          android:layout_gravity="center|bottom"
          android:background="@color/transparent"
          android:layout_marginBottom="75dp"
          android:orientation="vertical"
          android:id="@+id/fixedSubmitButtonlayout"&gt;
          &lt;TextView
              android:id="@+id/submit_users_btn"
              android:textColor="#757575"
              android:textAlignment="center"
              android:layout_width="match_parent"
              android:layout_height="40dp"
              android:background="@drawable/textview_border"
              android:letterSpacing="0.07"
              android:gravity="center"
              android:lineSpacingExtra="0sp"
              android:text="@string/register_guest_caps"
              android:textAppearance="@style/TextAppearance.Text.RidleyGrotesk.Regular"
              android:textSize="16sp"
              android:textStyle="normal" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>From the code above, the layout I am trying to fix at the bottom has id is: <code>android:id="@+id/fixedSubmitButtonlayout"</code>.</p>
  
  <p>I want it to stay intact/fixed at the bottom of the screen irrespective of the scrollview above it which is supposed to scroll behind it ( it does as of now, just the button position changes as the scroll view content overflows screen size). any ideas on how to fix this? </p>