Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RecyclerView items with big empty space after 23.2.0

After update to v23.2.0 in my RecyclerView I have items with huge empty vertical space, between the items.

My item layout is very simple:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"        android:layout_width="match_parent"        android:layout_height="match_parent"                                            android:orientation="vertical" > 
like image 484
Gabriele Mariotti Avatar asked Mar 01 '16 16:03

Gabriele Mariotti


2 Answers

According to the doc

With the release 23.2.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.

In your item layout you have to change:

android:layout_height="match_parent" 

with

android:layout_height="wrap_content"  
like image 102
Gabriele Mariotti Avatar answered Sep 18 '22 13:09

Gabriele Mariotti


You must make Recyclerview and item layout heights wrap content.

like image 42
Göksel Güren Avatar answered Sep 21 '22 13:09

Göksel Güren