title: Recyclerview in Coordinatorlayout cutting off last item
body: <p>I have a Bottom Navigation Bar, and a frame layout which is the fragment container. So when a an icon on a Bottom Navigation Bar is clicked, the fragment above changes.  </p>
  
  <p>In one of the fragment, I have a coordinator layout, collapsing toolbar, and recycler view. At the moment, the data is just a dummy data.  </p>
  
  <p>The <strong>problem</strong> that I am encountering is that whenever that fragment is inflated for the first time, the Recyclerview works fine and shows all of the items in the list. But when I change the fragment and come back to this fragment again, the last item of the Recyclerview is being cut off and is being hidden behind the Bottom Navigation Bar.  </p>
  
  <p>Here is my code for activity_home_screen.xml  </p>
  
  <pre><code>&lt;RelativeLayout 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"
  tools:context="com.smartinc.livesportstv.activities.HomeScreen"&gt;
  
  &lt;android.support.design.widget.BottomNavigationView
      android:id="@+id/bottom_nav"
      android:layout_width="match_parent"
      android:layout_height="55dp"
      android:layout_alignParentBottom="true"
      android:layout_gravity="bottom"
      app:itemBackground="?attr/colorPrimary"
      app:itemIconTint="@drawable/selector_bottombar_item"
      app:itemTextColor="@drawable/selector_bottombar_item"
      app:menu="@menu/bottombar_menu" /&gt;
  
  &lt;FrameLayout
      android:id="@+id/frame_fragmentholder"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_above="@id/bottom_nav"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"
      /&gt;
  </code></pre>
  
  <p>    </p>
  
  <p>Here is the fragment_events.xml  </p>
  
  <pre><code>&lt;android.support.design.widget.CoordinatorLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:fitsSystemWindows="true"
  android:id="@+id/coordinator"&gt;
  
  &lt;android.support.design.widget.AppBarLayout
      android:id="@+id/app_bar"
      android:layout_width="match_parent"
      android:layout_height="120dp"
      &gt;
  
      &lt;android.support.design.widget.CollapsingToolbarLayout
          android:id="@+id/collapsing_toolbar"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          app:contentScrim="@color/colorPrimary"
          android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
          app:layout_scrollFlags="scroll|exitUntilCollapsed"
          app:title="Events"
          app:expandedTitleTextAppearance="@style/TransparentText"
          app:collapsedTitleTextAppearance="@style/Toolbar_text_black"
          app:collapsedTitleGravity="center_horizontal"
          android:paddingEnd="20dp"
          android:fitsSystemWindows="true"
          &gt;
  
          &lt;!-- You can add views that you want to appear on the
               collapsing toolbar here --&gt;
  
          &lt;TextView
              android:id="@+id/events_title"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Events"
              android:textSize="30sp"
              android:textColor="@color/black"
              android:layout_marginTop="30dp"
              android:layout_marginStart="20dp"
              android:textStyle="bold"
              /&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="29 March, Thursday"
              android:textSize="20sp"
              android:textColor="@color/grey_800"
              android:layout_marginTop="70dp"
              android:layout_marginStart="20dp"
              /&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"
              android:minHeight="?attr/actionBarSize"
              app:layout_scrollFlags="scroll|enterAlways"
              android:gravity="center_horizontal"
              app:popupTheme="@style/AppTheme"
              app:contentInsetLeft="0dp"
              app:contentInsetStart="0dp"
              /&gt;
  
      &lt;/android.support.design.widget.CollapsingToolbarLayout&gt;
  
  &lt;/android.support.design.widget.AppBarLayout&gt;
  
  &lt;android.support.v7.widget.RecyclerView
      android:id="@+id/recycler_view_events"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"
      /&gt;
  
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Request"
      android:textSize="17sp"
      android:layout_gravity="end"
      android:textColor="@color/colorPrimaryDark"
      android:padding="10dp"
      android:layout_marginEnd="10dp"
      android:layout_marginTop="5dp"
      /&gt;
  </code></pre>
  
  <p>  </p>
  
  <p>Here is HomeScreen.java  </p>
  
  <pre><code>public class HomeScreen extends AppCompatActivity {
  
  private BottomNavigationView bottomNavigationView;
  
  private String fragName = "";
  
  @Override
  public void startActivity(Intent intent) {
      super.startActivity(intent);
      Constants.overridePendingTransitionEnter(this);
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_home_screen);
  
      init();
      setMainFragment();
      setBottomNavigation();
  }
  
  private void init(){
      bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_nav);
  
  
  }
  
  private void setBottomNavigation(){
      bottomNavigationView.setOnNavigationItemSelectedListener(
              new BottomNavigationView.OnNavigationItemSelectedListener() {
                  @Override
                  public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                      switch (item.getItemId()) {
                          case R.id.bottombaritem_events:
                              if(!fragName.equals("events")) {
                                  FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
                                  ft.setCustomAnimations(R.anim.left_slide_in, R.anim.right_slide_out);
                                  ft.replace(R.id.frame_fragmentholder, new EventsFragment());
                                  ft.commit();
                                  fragName = "events";
                              }
                              return true;
                          case R.id.bottombaritem_channels:
                              FragmentTransaction ft2 = getSupportFragmentManager().beginTransaction();
                              if(fragName.equals("events")) {
                                  ft2.setCustomAnimations(R.anim.right_slide_in, R.anim.left_slide_out);
                              } else {
                                  ft2.setCustomAnimations(R.anim.left_slide_in, R.anim.right_slide_out);
                              }
  
                              ft2.replace(R.id.frame_fragmentholder, new ChannelsFragment());
                              ft2.commit();
                              fragName = "channels";
                              return true;
                          case R.id.bottombaritem_more:
                              if(!fragName.equals("more")) {
                                  FragmentTransaction ft3 = getSupportFragmentManager().beginTransaction();
                                  ft3.setCustomAnimations(R.anim.right_slide_in, R.anim.left_slide_out);
                                  ft3.replace(R.id.frame_fragmentholder, new MoreFragment());
                                  ft3.commit();
                                  fragName = "more";
                              }
                              return true;
                      }
                      return false;
                  }
              });
  }
  
  private void setMainFragment(){
      fragName = "events";
      FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
      ft.replace(R.id.frame_fragmentholder, new EventsFragment());
      ft.commit();
  }
  
  @Override
  public void onBackPressed() {
      super.onBackPressed();
      Constants.overridePendingTransitionExit(this);
  }
  </code></pre>
  
  <p>}  </p>
  
  <p>And here is EventsFragment.java  </p>
  
  <pre><code>public class EventsFragment extends Fragment {
  
  private RecyclerView mRecyclerView;
  private ArrayList&lt;String&gt; mData;
  
  private CollapsingToolbarLayout collapsing_toolbar;
  
  private Context mContext;
  
  public EventsFragment() {
      // Required empty public constructor
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      // Inflate the layout for this fragment
      View view =  inflater.inflate(R.layout.fragment_events, container, false);
  
      mContext = getActivity();
  
      final CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) view.findViewById(R.id.collapsing_toolbar);
      AppBarLayout appBarLayout = (AppBarLayout) view.findViewById(R.id.app_bar);
      appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
          boolean isShow = true;
          int scrollRange = -1;
  
          @Override
          public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
              if (scrollRange == -1) {
                  scrollRange = appBarLayout.getTotalScrollRange();
              }
              if (scrollRange + verticalOffset == 0) {
                  collapsingToolbarLayout.setTitle("Events");
                  isShow = true;
              } else if(isShow) {
                  collapsingToolbarLayout.setTitle(" ");//carefull there should a space between double quote otherwise it wont work
                  isShow = false;
              }
          }
      });
  
      // Initialize the RecyclerView
      mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view_events);
      setUpRecyclerView();
  
      return view;
  }
  
  private void setUpRecyclerView() {
      LinearLayoutManager llm = new LinearLayoutManager(mContext);
      llm.setAutoMeasureEnabled(true);
      mRecyclerView.setLayoutManager(llm);
  
      EventsAdapter eventsAdapter = new EventsAdapter(mContext);
      mRecyclerView.setAdapter(eventsAdapter);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Any help would be really appreciated. Thanks!</p>