title: RecyclerView is cutting off the last item
body: <p>I have a fragment with a toolbar and a recyclerView inside it.</p>
  
  <p>I am populating the recyclerView with dummy data and then try to show them. For some reason, the last element of the recyclerView is getting cut-off.</p>
  
  <p>This is the XML of the fragment:</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"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@color/background_1"
      android:fitsSystemWindows="true"&gt;
  
      &lt;android.support.design.widget.AppBarLayout
          android:id="@+id/appbar_layout"
          android:layout_width="match_parent"
          android:layout_height="@dimen/height_of_app_bar"
          android:fitsSystemWindows="true"
          android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&gt;
  
          &lt;android.support.design.widget.CollapsingToolbarLayout
              android:id="@+id/collapsing_toolbar"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:fitsSystemWindows="true"
              app:contentScrim="@color/primary"
              app:expandedTitleMarginEnd="64dp"
              app:expandedTitleMarginStart="48dp"
              app:layout_scrollFlags="scroll|exitUntilCollapsed"&gt;
  
              &lt;ImageView
                  android:id="@+id/backdrop"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:fitsSystemWindows="true"
                  android:scaleType="centerCrop"
                  android:src="@drawable/placeholder_rect_header"
                  app:layout_collapseMode="parallax"/&gt;
  
              &lt;android.support.v7.widget.Toolbar
                  android:id="@+id/toolbar"
                  android:layout_width="match_parent"
                  android:layout_height="?attr/actionBarSize"
                  app:layout_collapseMode="pin"
                  app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/&gt;
  
          &lt;/android.support.design.widget.CollapsingToolbarLayout&gt;
  
      &lt;/android.support.design.widget.AppBarLayout&gt;
  
      &lt;android.support.v7.widget.RecyclerView
          android:id="@+id/simpleList"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          app:layout_behavior="@string/appbar_scrolling_view_behavior"/&gt;
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>The items at the list are really simple ones:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="200dp"
      android:background="@color/background_1"
      android:orientation="horizontal"
      android:padding="@dimen/space_for_a_bit_of_air"&gt;
  
      &lt;ImageView
          android:id="@+id/album_cover"
          android:layout_width="100dp"
          android:layout_height="100dp"
          android:layout_gravity="center_vertical"
          android:scaleType="fitXY"
          android:src="@drawable/placeholder_album_cover"/&gt;
  
      &lt;LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center_vertical"
          android:layout_marginLeft="@dimen/space_for_distinguishing_stuff"
          android:orientation="vertical"&gt;
  
          &lt;TextView
              android:id="@+id/album_title"
              style="@style/titleText"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/sample_text_c"/&gt;
  
          &lt;TextView
              android:id="@+id/album_year"
              style="@style/subtitleText"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/sample_text_a"/&gt;
  
      &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/KEYzu.png"><img src="https://i.stack.imgur.com/KEYzu.png" alt="I am now at the end of the list, but the last element still looks cut-off"></a></p>
  
  <p>I am now at the end of the list, but the last element still looks cut-off.</p>
  
  <p>I am using the latest version as of 2015-09-23 of google libraries, 23.0.1, (i.e. com.android.support:recyclerview-v7:23.0.1), and the following configuration at the build.gradle:</p>
  
  <pre><code>compileSdkVersion 23
  buildToolsVersion "23.0.1"
  
  defaultConfig {
     minSdkVersion 14
     targetSdkVersion 23
     versionCode 1
     versionName "1.0"
  
     multiDexEnabled true// Enabling multidex support
   }
  </code></pre>
  
  <p>Any help would be greatly appreciated since I am going nuts with this problem :(</p>
  
  <h2>SOLUTION</h2>
  
  <p>Ok, after cleaning the code to the bare essentials and removing complexity, I found the problem: it was a combination of wrong flags and missing or extra attributes. The following works fine for both Android 4.x and 5.x:</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/background_1"
      android:fitsSystemWindows="true"&gt;
  
      &lt;android.support.design.widget.AppBarLayout
          android:id="@+id/appbar_layout"
          android:layout_width="match_parent"
          android:layout_height="@dimen/height_of_app_bar"
          android:fitsSystemWindows="true"&gt;
  
          &lt;android.support.design.widget.CollapsingToolbarLayout
              android:id="@+id/collapsing_toolbar"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:fitsSystemWindows="true"
              app:collapsedTitleTextAppearance="@style/Title.collapsed"
              app:contentScrim="@color/primary"
              app:expandedTitleMarginStart="48dp"
              app:expandedTitleTextAppearance="@style/Title.Expanded"
              app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"&gt;
  
              &lt;ImageView
                  android:id="@+id/backdrop"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:fitsSystemWindows="true"
                  android:scaleType="centerCrop"
                  android:src="@drawable/artistic_4"
                  app:layout_collapseMode="parallax"/&gt;
  
              &lt;View
                  android:layout_width="match_parent"
                  android:layout_height="@dimen/height_of_app_bar"
                  android:background="@drawable/gradient"/&gt;
  
              &lt;android.support.v7.widget.Toolbar
                  android:id="@+id/toolbar"
                  android:layout_width="match_parent"
                  android:layout_height="?attr/actionBarSize"
                  app:layout_collapseMode="pin"/&gt;
  
          &lt;/android.support.design.widget.CollapsingToolbarLayout&gt;
  
      &lt;/android.support.design.widget.AppBarLayout&gt;
  
      &lt;android.support.v7.widget.RecyclerView
          android:id="@+id/simpleList"
          style="@style/genericRecyclerView"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          app:layout_behavior="@string/appbar_scrolling_view_behavior"
          tools:listitem="@layout/item_discography_album"/&gt;
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>In a nutshell, android:fitsSystemWindows="true" should only be at the coordinatorLayout, AppBarLayout and theCollapsingToolbarLayout (which are the ones that we want to be adjusted based on the screen on Android 5.x), the app:layout_scrollFlags should be set to "scroll|enterAlways|enterAlwaysCollapsed" and the toolbar should have as height, the height of the actionBar. Finally, it's better to keep the RecyclerView as clean as possible so you can control the layout spacing at each line item.</p>