title: RecyclerView scroll to position when a new item is added
body: <p>I want my RecyclerView to scroll to the bottom when a new item is added to the list. Below is my code:</p>
  
  <pre><code>RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
  recyclerView.setLayoutManager(layoutManager);
  
  adapter = new RecyclerViewAdapter(data, recyclerView);
  recyclerView.setAdapter(adapter);
  </code></pre>
  
  <p>And when I click a button which is below the <code>RecyclerView</code>, data is added to the list:</p>
  
  <pre><code>public void addNewCard() {
      data.add("New");
      adapter.notifyItemInserted(data.size() - 1);
      recyclerView.scrollToPosition(data.size() - 1);
  }
  </code></pre>
  
  <p>Whenever I add an item, it always gets scrolled up to the topmost position. I tried using <code>smoothScrollToPosition()</code> and tried using <code>scrollToPosition()</code> on <code>LinearLayoutManager</code> too. I even tried using <code>ViewTreeObserver</code>. Tried changing the version of <code>RecyclerView</code> in dependencies too. I searched thoroughly on Stack Overflow and none of the solutions work for me. </p>
  
  <p>Any ideas on what could be the problem? I'm using <code>RecyclerView</code> inside a fragment. Could that be a cause of the problem?</p>
  
  <p>My .xml file for the <code>RecyclerView</code></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v4.widget.NestedScrollView 
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/scroll_view_recycler"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  
  &lt;RelativeLayout
      android:id="@+id/rel_layout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"&gt;
  
      &lt;android.support.v7.widget.RecyclerView
          android:id="@+id/listView"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginTop="6dp" /&gt;
  
      &lt;Button
          android:id="@+id/button_add_new_card"
          style="@style/Widget.AppCompat.Button.Borderless"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_below="@id/listView"
          android:layout_marginBottom="16dp"
          android:layout_marginTop="8dp"
          android:padding="20dp"
          android:text="+ Add new Item" /&gt;
  &lt;/RelativeLayout&gt;
  &lt;/android.support.v4.widget.NestedScrollView&gt;
  </code></pre>