RecyclerView space between items expanding when scrolling RecyclerView space between items expanding when scrolling xml xml

RecyclerView space between items expanding when scrolling


Provide your Layout and RecyclerView code to help debug and not make a guess.

Ok so here is the issue:

With the release 2.3.0 there is an exciting new feature to the LayoutManager API: auto-measurement! This allows a RecyclerView to size itself based on the size of its contents. This means that previously unavailable scenarios, such as using WRAP_CONTENT for a dimension of the RecyclerView, are now possible. You’ll find all built in LayoutManagers now support auto-measurement.

Due to this change, make sure to double check the layout parameters of your item views: previously ignored layout parameters (such as MATCH_PARENT in the scroll direction) will now be fully respected.

Basically you need to remove the LinearLayout

<ImageViewandroid:id="@+id/imageView_slide"android:layout_width="60dp"android:layout_height="60dp"android:layout_margin="5dp"android:background="@android:color/darker_gray" />

The match_parent in the LinearLayout width is causing each item to fit the entire screen with one image and remaining space.

If you insist on using the LinearLayout, set both width and height to wrap_content