title: Grid Items in RecyclerView not appearing properly
body: <p>For some reason, the contents of my RecyclerView (i.e. letters from a <code>String</code> array) do not appear as excepted. There should be 6 letters that appear but only 2 of them do. I already used <code>android:layout_height="wrap_content"</code> for both the RecyclerView itself and its parent but that still hasn't made a difference.</p>
  
  <p><a href="https://i.stack.imgur.com/4Bt6x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4Bt6x.png" alt="enter image description here"></a></p>
  
  <p><strong>CardView XML containing RecyclerView (for Grid)</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v7.widget.CardView
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:clickable="true"
      android:focusable="true"
      android:id="@+id/cardview_gv"&gt;
  
      &lt;LinearLayout
          android:id="@+id/cardview_gv_main"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"
          android:padding="10dp"
          android:animateLayoutChanges="true"&gt;
  
          &lt;LinearLayout
              android:id="@+id/cardview_gv_titlerow"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="horizontal"
              android:weightSum="100"&gt;
  
              &lt;TextView
                  android:id="@+id/tv_gv_title"
                  android:layout_weight="90"
                  android:layout_width="0dp"
                  android:layout_height="wrap_content"
                  android:textColor="?android:attr/textColorPrimary"
                  style="@android:style/TextAppearance.Medium" /&gt;
  
              &lt;TextView
                  android:id="@+id/tv_gv_expandcollapse"
                  android:clickable="true"
                  android:focusable="true"
                  android:layout_weight="10"
                  android:layout_width="0dp"
                  android:layout_height="wrap_content"
                  android:layout_marginStart="10dp" /&gt;
          &lt;/LinearLayout&gt;
  
          &lt;RelativeLayout
              android:id="@+id/relativelayout_gv"
              android:animateLayoutChanges="true"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"&gt;
  
              &lt;android.support.v7.widget.RecyclerView
                  xmlns:android="http://schemas.android.com/apk/res/android"
                  android:id="@+id/rv"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:nestedScrollingEnabled="false"
                  android:overScrollMode="never"
                  android:scrollbars="none" /&gt;
          &lt;/RelativeLayout&gt;
      &lt;/LinearLayout&gt;
  &lt;/android.support.v7.widget.CardView&gt;
  </code></pre>
  
  <p><strong>RecyclerView-related code in Fragment</strong></p>
  
  <pre><code>                static final String[] frenchVowels = new String[]{
                      "a", "e", "i", "o", "u", "y"
                  };
  
                  RecyclerViewAdapter rvAdapterGL;
                  final RecyclerView rvGL = viewHolder.itemView.findViewById(R.id.rv);
                  int numberOfColumns = 2;
                  rvGL.setLayoutManager(new GridLayoutManager(getActivity(), numberOfColumns));
                  rvAdapterGL = new RecyclerViewAdapter(getActivity(), frenchVowels);
                  rvGL.setAdapter(rvAdapterGL);
  </code></pre>
  
  <p><strong>RecyclerView adapter class</strong></p>
  
  <pre><code>public class RecyclerViewAdapter extends RecyclerView.Adapter&lt;RecyclerViewAdapter.ViewHolder&gt; {
  
      private String[] mData;
      private LayoutInflater mInflater;
  
      // data is passed into the constructor
      public RecyclerViewAdapter(Context context, String[] data) {
          this.mInflater = LayoutInflater.from(context);
          this.mData = data;
      }
  
      // inflates the cell layout from xml when needed
      @Override
      @NonNull
      public RecyclerViewAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
          View view = mInflater.inflate(R.layout.gridview_item, parent, false);
          return new RecyclerViewAdapter.ViewHolder(view);
      }
  
      // binds the data to the TextView in each cell
      @Override
      public void onBindViewHolder(@NonNull RecyclerViewAdapter.ViewHolder holder, int position) {
          holder.myTextView.setText(mData[position]);
      }
  
      // total number of cells
      @Override
      public int getItemCount() {
          return mData.length;
      }
  
  
      // stores and recycles views as they are scrolled off screen
      public class ViewHolder extends RecyclerView.ViewHolder {
          TextView myTextView;
  
          ViewHolder(View itemView) {
              super(itemView);
              myTextView = itemView.findViewById(R.id.item_gridview);
          }
      }
  }
  </code></pre>
  
  <p><strong>gridview_item.xml</strong></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="match_parent" &gt;
  
      &lt;TextView
          android:id="@+id/item_gridview"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:paddingStart="0dp"
          android:paddingEnd="10dp"
          android:paddingTop="10dp"
          android:paddingBottom="10dp"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>