title: RecyclerView inside a ScrollView/NestedScrollView does not scroll properly
body: <p>I have a layout which has a <code>CardView</code> and a <code>FloatingActionButton</code> associated with it. There is a list of replies below the <code>CardView</code> (which is a <code>RecyclerView</code>). Sometimes the <code>CardViews'</code> height is greater than the screen, so I have used <code>layout_height="wrap_content"</code> for the <code>CardView</code> and wrapped the whole <code>LinearLayout</code> inside a <code>ScrollView</code>.</p>
  
  <p>However, this causes a problem(since it is a scrolling view inside a <code>ScrollView</code>) while scrolling the items of the <code>RecyclerView</code>. As suggested in some of the <a href="https://stackoverflow.com/questions/27083091/recyclerview-inside-scrollview-is-not-working">questions</a> and <a href="https://stackoverflow.com/a/6211286/2863440">answers</a> posted, I have used both the <code>NestedScrollView</code> and the <code>android:nestedScrollingEnabled="true"</code> tag but the scrolling in the <code>RecyclerView</code> is still bad.</p>
  
  <p>Here is my <code>Layout</code> file - </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"
      tools:context="com.example.forum.reply.ReplyActivity"&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"&gt;
  
          &lt;android.support.v7.widget.Toolbar
              android:id="@+id/reply_toolbar"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:background="?attr/colorPrimary"
              android:minHeight="?attr/actionBarSize"
              android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
              app:titleTextColor="@android:color/white"/&gt;
  
          &lt;ScrollView
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:nestedScrollingEnabled="true"
              android:fillViewport="true"&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_margin="8dp"
                  android:orientation="vertical"&gt;
  
                  &lt;android.support.v7.widget.CardView
                      android:id="@+id/topic_card"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:paddingBottom="@dimen/card_margin"
                      android:paddingLeft="@dimen/card_margin"
                      android:paddingRight="@dimen/card_margin"
                      android:paddingTop="@dimen/card_margin"&gt;
  
                      &lt;LinearLayout
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"
                          android:orientation="vertical"
                          android:paddingEnd="@dimen/card_margin"
                          android:paddingStart="@dimen/card_margin"&gt;
  
                          &lt;android.support.v7.widget.AppCompatTextView
                              android:id="@+id/topic_title"
                              android:layout_width="match_parent"
                              android:layout_height="wrap_content"
                              android:layout_marginBottom="8dp"
                              android:layout_marginTop="8dp"
                              android:textAppearance="@style/TextAppearance.AppCompat.Title"/&gt;
  
                          &lt;android.support.v7.widget.AppCompatTextView
                              android:id="@+id/topic_content"
                              android:layout_width="match_parent"
                              android:layout_height="wrap_content"
                              android:textAppearance="@style/TextAppearance.AppCompat.Body1"/&gt;
                      &lt;/LinearLayout&gt;
                  &lt;/android.support.v7.widget.CardView&gt;
  
                  &lt;ProgressBar
                      android:id="@+id/reply_progressbar"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_gravity="center"
                      android:indeterminate="true"
                      android:visibility="visible"/&gt;
  
                  &lt;android.support.v7.widget.RecyclerView
                      android:id="@+id/list_of_replies"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:visibility="invisible"/&gt;
              &lt;/LinearLayout&gt;
          &lt;/ScrollView&gt;
      &lt;/LinearLayout&gt;
  
      &lt;android.support.design.widget.FloatingActionButton
          android:id="@+id/reply_to_topic"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_margin="16dp"
          android:clickable="true"
          android:src="@drawable/ic_reply_white_24dp"
          app:layout_anchor="@id/topic_card"
          app:layout_anchorGravity="bottom|right|end"/&gt;
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>Here are some images - </p>
  
  <p><a href="https://i.stack.imgur.com/Q97Iw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Q97Iw.png" alt="CardView with FloatingActionButton visible"></a></p>
  
  <p><a href="https://i.stack.imgur.com/c4VXz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/c4VXz.png" alt="Scrolling from the CardView to RecyclerView is smooth"></a></p>
  
  <p><a href="https://i.stack.imgur.com/fTn9k.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fTn9k.png" alt="Scrolling down isn&#39;t smooth"></a></p>
  
  <p><a href="https://i.stack.imgur.com/wUZca.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wUZca.png" alt="Scrolling up also isn&#39;t smooth"></a></p>