title: Scrolling RecyclerView inside CardView is very slow
body: <p>I have 4 CardViews in a Activity and each CardView has a RecyclerView. Each RecyclerView has around 8-10 rows/item. Scrolling of this page/activity is very slow.
  I suspect some problem in my RecyclerView.Adapter class.
  Can somebody please let me know what could be the issue in my code?</p>
  
  <h1>Adapter:</h1>
  
  <pre><code>import android.support.v7.widget.RecyclerView;
  import android.text.Html;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.TextView;
  
  import java.util.ArrayList;
  
  public class JyotishAppAdapter extends RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt; {
  
      private ArrayList&lt;DataModel&gt; dataList;
      private int cardView;
      public static final int CARD_2_COL = 0;
      public static final int CARD_3_COL_HEAD = 1;
      public static final int CARD_2_COL2 = 2;
  
      public static class GenericViewHolder extends RecyclerView.ViewHolder {
  
          TextView itemName;
          TextView itemDescription;
  
          public GenericViewHolder (View itemView) {
              super (itemView);
              this.itemName = (TextView) itemView.findViewById(R.id.item_name);
              this.itemDescription = (TextView) itemView.findViewById(R.id.item_description);
          }
      }
  
      public static class GenericViewHolder2 extends RecyclerView.ViewHolder {
  
          TextView itemName;
          TextView itemDescription;
          TextView itemStatus;
  
          public GenericViewHolder2 (View itemView) {
              super (itemView);
              this.itemName = (TextView) itemView.findViewById(R.id.item_name);
              this.itemDescription = (TextView) itemView.findViewById(R.id.item_description);
              this.itemStatus = (TextView) itemView.findViewById(R.id.item_status);
          }
      }
  
      public JyotishAppAdapter(ArrayList&lt;DataModel&gt; dataList, int cardView) {
          this.dataList = dataList;
          this.cardView = cardView;
      }
  
      @Override
      public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
  
          View v;
          if (cardView == CARD_2_COL) {
              v = LayoutInflater.from(viewGroup.getContext())
                      .inflate(R.layout.list_item, viewGroup, false);
              return new GenericViewHolder(v);
  
          } else if (cardView == CARD_2_COL2) {
              v = LayoutInflater.from(viewGroup.getContext())
                      .inflate(R.layout.list_item3, viewGroup, false);
              return new GenericViewHolder(v);
          } else {
              v = LayoutInflater.from(viewGroup.getContext())
                      .inflate(R.layout.list_item2, viewGroup, false);
              return new GenericViewHolder2(v);
          }
      }
  
      @Override
      public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, final int position) {
  
          final DataModel dataModel = dataList.get(position);
  
          if (viewHolder instanceof GenericViewHolder) {
              GenericViewHolder holder = (GenericViewHolder) viewHolder;
              holder.itemName.setText(Html.fromHtml(dataModel.getValue1()));
              holder.itemDescription.setText(Html.fromHtml(dataModel.getValue2()));
  
              if (dataModel.getValue4() != null) {
                  holder.itemView.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(View view) {
                          Utility.showAlertMessage(view.getContext(), R.string.message_title,
                                  Html.fromHtml(dataModel.getValue4()).toString());
                      }
                  });
              }
          } else {
              GenericViewHolder2 holder = (GenericViewHolder2) viewHolder;
              holder.itemName.setText(Html.fromHtml(dataModel.getValue1()));
              holder.itemDescription.setText(Html.fromHtml(dataModel.getValue2()));
              holder.itemStatus.setText(Html.fromHtml(dataModel.getValue3()));
  
              if (dataModel.getValue4() != null) {
                  holder.itemView.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(View view) {
                          Utility.showAlertMessage(view.getContext(), R.string.message_title,
                                  Html.fromHtml(dataModel.getValue4()).toString());
                      }
                  });
              }
          }
      }
  
      @Override
      public int getItemCount() {
          return dataList.size();
      }
  
  }
  </code></pre>
  
  <h1>Activity.xml</h1>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:card_view="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@color/PageContentBackground"
      tools:context=".PanchangaActivity"&gt;
  
      &lt;include android:id="@+id/tool_bar"
          layout="@layout/tool_bar" /&gt;
  
      &lt;LinearLayout android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/tool_bar"
          android:orientation="vertical"
          android:paddingTop="@dimen/activity_vertical_margin"
          android:paddingRight="@dimen/activity_horizontal_margin"
          android:paddingLeft="@dimen/activity_horizontal_margin"
          android:paddingBottom="@dimen/activity_vertical_margin"
          android:background="@color/PageContentBackground"&gt;
  
          &lt;TextView android:id="@+id/muhurta_zone"
              style="@style/TextStyle"
              android:textSize="@dimen/text_size_horo_data"
              android:ellipsize="none"
              android:scrollHorizontally="false"
              android:layout_marginBottom="5dp"/&gt;
          &lt;TextView android:id="@+id/muhurta_place"
              style="@style/TextStyle"
              android:textSize="@dimen/text_size_horo_data"
              android:ellipsize="none"
              android:scrollHorizontally="false"
              android:layout_marginBottom="10dp"/&gt;
  
          &lt;ScrollView android:layout_height="wrap_content"
              android:layout_width="match_parent"&gt;
              &lt;RelativeLayout android:layout_width="match_parent"
                  android:layout_height="wrap_content"&gt;
  
                  &lt;android.support.v7.widget.CardView
                      android:id="@+id/cardview4"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_marginTop="5dp"
                      card_view:cardElevation="5dp"
                      card_view:cardCornerRadius="5dp"
                      card_view:cardUseCompatPadding="true"
                      card_view:cardBackgroundColor="@color/CardViewColor"&gt;
  
                      &lt;android.support.v7.widget.RecyclerView
                          android:id="@+id/panchanga_result_1"
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"
                          android:background="@color/CardViewColor"
                          android:paddingLeft="3dp"
                          android:paddingRight="3dp" /&gt;
                  &lt;/android.support.v7.widget.CardView&gt;
  
                  &lt;android.support.v7.widget.CardView
                      android:id="@+id/cardview5"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_below="@+id/cardview4"
                      android:layout_marginTop="10dp"
                      card_view:cardElevation="5dp"
                      card_view:cardCornerRadius="5dp"
                      card_view:cardUseCompatPadding="true"
                      card_view:cardBackgroundColor="@color/CardViewColor"&gt;
  
                      &lt;android.support.v7.widget.RecyclerView
                          android:id="@+id/panchanga_result_2"
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"
                          android:background="@color/CardViewColor"
                          android:paddingLeft="3dp"
                          android:paddingRight="3dp" /&gt;
                  &lt;/android.support.v7.widget.CardView&gt;
  
                  &lt;android.support.v7.widget.CardView
                      android:id="@+id/cardview6"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_below="@+id/cardview5"
                      android:layout_marginTop="10dp"
                      card_view:cardElevation="5dp"
                      card_view:cardCornerRadius="5dp"
                      card_view:cardUseCompatPadding="true"
                      card_view:cardBackgroundColor="@color/CardViewColor"&gt;
  
                      &lt;android.support.v7.widget.RecyclerView
                          android:id="@+id/panchanga_result_3"
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"
                          android:background="@color/CardViewColor"
                          android:paddingLeft="3dp"
                          android:paddingRight="3dp" /&gt;
                  &lt;/android.support.v7.widget.CardView&gt;
  
                  &lt;android.support.v7.widget.CardView
                      android:id="@+id/cardview7"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_below="@+id/cardview6"
                      android:layout_marginTop="10dp"
                      card_view:cardElevation="5dp"
                      card_view:cardCornerRadius="5dp"
                      card_view:cardUseCompatPadding="true"
                      card_view:cardBackgroundColor="@color/CardViewColor"&gt;
  
                      &lt;android.support.v7.widget.RecyclerView
                          android:id="@+id/panchanga_result_4"
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"
                          android:background="@color/CardViewColor"
                          android:paddingLeft="3dp"
                          android:paddingRight="3dp" /&gt;
                  &lt;/android.support.v7.widget.CardView&gt;
  
              &lt;/RelativeLayout&gt;
          &lt;/ScrollView&gt;
      &lt;/LinearLayout&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>