title: Android RecyclerView large gap space after some rows of items on tablet landscape
body: <p>There are large random placed gaps appearing in between the rows of views in my RecyclerView, same like other users noted in bellow questions.</p>
  
  <p>I have looked into suggested solutions from other questions like:</p>
  
  <p><a href="https://stackoverflow.com/questions/35817610/large-gap-forms-between-recyclerview-items-when-scrolling-down">Large gap forms between RecyclerView items when scrolling down</a></p>
  
  <p><a href="https://stackoverflow.com/questions/39476611/large-gap-between-recyclerview-items">Large gap between RecyclerView items</a></p>
  
  <p><a href="https://stackoverflow.com/questions/35728179/recyclerview-items-with-big-empty-space-after-23-2-0">RecyclerView items with big empty space after 23.2.0</a></p>
  
  <p><a href="https://stackoverflow.com/questions/39522509/android-recyclerview-blank-space">Android RecyclerView Blank Space</a></p>
  
  <p><a href="https://stackoverflow.com/questions/40521577/recyclerview-space-between-items-on-android-application">RECYCLERVIEW SPACE BETWEEN ITEMS ON ANDROID APPLICATION</a></p>
  
  <p><a href="https://stackoverflow.com/questions/36068857/recyclerview-items-with-very-large-empty-space-at-bottom-after-updating-to-suppo">RecyclerView items with very large empty space at bottom after updating to support library 23.2.1</a></p>
  
  <p>but they all seam to suggest the same thing: change match_parent to wrap_content in your layouts. As it can be seen from the layout code bellow, I have tried that, but I still get the same gaps.</p>
  
  <p>I need to note that these gaps are present only in tablets in the landscape.</p>
  
  <p>My layouts:</p>
  
  <p>content_main.xml:</p>
  
  <pre><code>&lt;FrameLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/fragment_container"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"
      /&gt;
  </code></pre>
  
  <p>content_main.xml in layout-sw600pd-port:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:id="@+id/llTwoPane"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:baselineAligned="true"
                android:divider="?android:attr/dividerHorizontal"
                android:orientation="horizontal"
                android:paddingTop="@dimen/gap_xl"
                tools:context=".MainActivity"&gt;
  
      &lt;fragment
          android:id="@+id/fragment_main"
          android:name=".MainFragment"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          tools:layout="@android:layout/list_content" /&gt;
  
      &lt;FrameLayout
          android:id="@+id/fragment_container"
          android:layout_width="0dp"
          android:layout_height="match_parent"
          android:layout_weight="@integer/parts_fd"
          app:layout_behavior="@string/appbar_scrolling_view_behavior"
          /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>content_main.xml in layout-sw600pd</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:id="@+id/llTwoPane"
                android:layout_width="match_parent"
              android:layout_height="wrap_content"
                android:baselineAligned="true"
                android:orientation="horizontal"
                android:paddingTop="@dimen/gap_xl"&gt;
  
      &lt;fragment
          android:id="@+id/fragment_main"
          android:name=".MainFragment"
          android:layout_width="0dp"
          android:layout_weight="@integer/parts_fm"
        android:layout_height="wrap_content"
          tools:layout="@android:layout/list_content" /&gt;
  
      &lt;FrameLayout
          android:id="@+id/fragment_container"
          android:layout_width="0dp"
          android:layout_height="match_parent"
          android:layout_weight="@integer/parts_fd"
          app:layout_behavior="@string/appbar_scrolling_view_behavior"
          /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>fragment_main.xml:</p>
  
  <pre><code>&lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/llFragmentMain"
      android:layout_width="match_parent"
    android:layout_height="wrap_content"
      android:orientation="vertical"
      tools:context=".MainFragment"
      tools:showIn="@layout/activity_main"
      android:background="@color/colorGray"
      &gt;
  
      &lt;Spinner
          android:id="@+id/spnSort"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:textAlignment="center"
          android:paddingTop="@dimen/title_gap"
          android:paddingBottom="@dimen/title_gap"
          android:paddingLeft="@dimen/gap_m"
          android:paddingRight="@dimen/gap_m"
          /&gt;
  
      &lt;android.support.v7.widget.RecyclerView
          android:id="@+id/rvPosters"
          android:layout_width="match_parent"
        android:layout_height="wrap_content"
          android:padding="@dimen/half_poster_spacing"
          android:background="@color/colorLight"
          android:scrollbars="vertical"
          android:animateLayoutChanges="false"
          android:scrollbarThumbHorizontal="@drawable/scrollbar"
          /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>item.xml inflated in adapter:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/flPosterItem"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_margin="@dimen/half_poster_spacing"
      android:descendantFocusability="blocksDescendants"
      &gt;
      &lt;ImageView
          android:id="@+id/imvPoster"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:adjustViewBounds="true"
          android:contentDescription="@string/poster_content_description"
          /&gt;
      &lt;Button
          android:id="@+id/btnFavouriteInMain"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:minHeight="0dp"
          android:minWidth="@dimen/fav_button_minw"
          android:paddingBottom="@dimen/fav_button_padding"
          android:paddingLeft="@dimen/fav_button_padding"
          android:paddingStart="@dimen/fav_button_padding"
          android:paddingRight="@dimen/fav_button_padding"
          android:paddingEnd="@dimen/fav_button_padding"
          android:background="@color/colorButtonStarBgd"
          android:textStyle="bold"
          android:textAlignment="center"
          android:textSize="@dimen/text_size_m"
          android:layout_gravity="bottom|end"
          /&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>I set my RecyclerView with:    </p>
  
  <pre><code>recyclerView.setLayoutManager(posterAdapter.getGridLayoutManager());
  recyclerView.setHasFixedSize(true);
  recyclerView.setNestedScrollingEnabled(false);
  recyclerView.setAdapter(posterAdapter);
  </code></pre>
  
  <p>And grid layout manager is set with:</p>
  
  <pre><code>GridLayoutManager getGridLayoutManager() {
      GridLayoutManager gridLayoutManager = new GridLayoutManager(context, mNumberOfColumns);
      gridLayoutManager.setSmoothScrollbarEnabled(true);
      gridLayoutManager.setAutoMeasureEnabled(true);
      gridLayoutManager.setSpanCount(mNumberOfColumns);
      return gridLayoutManager;
  }
  </code></pre>
  
  <p>On phones gaps don't appear in any orientation. On tablets, in portrait there is only one column. Even with match_parent the gaps do not appear. In landscape there are three to four columns and gaps appear even with wrap_content and it's always between full rows. </p>
  
  <p>I have tried to remove </p>
  
  <ul>
  <li><code>recyclerView.setHasFixedSize(true);</code></li>
  <li><code>ridLayoutManager.setAutoMeasureEnabled(true);</code></li>
  <li>and to make item.xml image only (make button gone)</li>
  </ul>
  
  <p>but no use.</p>
  
  <p>Does anyone have some other explanation?</p>