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 simp
You must make Recyclerview and item layout heights wrap content.
This is work for me.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="100dp"
android:elevation="7dp"
app:cardCornerRadius="7dp"
app:cardMaxElevation="7dp"
app:contentPadding="7dp"
android:layout_margin="5dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tv_allfeedbacks_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:textSize="14dp"
android:textStyle="bold"
/>
<TextView
android:id="@+id/tv_allfeedback_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
/>
<TextView
android:id="@+id/tv_allfeedbacks_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_allfeedbacks_title"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
/>
<TextView
android:id="@+id/tv_allfeedbacks_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="5dp"
/>
<RatingBar
android:id="@+id/ratingbar_allfeedbacks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:numStars="5"
android:layout_margin="5dp"
style="?attr/ratingBarStyleSmall"
/>
</RelativeLayout>
</android.support.v7.widget.CardView>
None of the given Solution worked.
Setting layout_height = "wrap_content"
did not work either.
Parent layout of my list design is ConstraintLayout and that was the problem(don't know what). But after changing parent layout to RelativeLayout everything work fine.
In my case, I had made the new wrap_content changes but there was still a gap that manifested during onMove or onSwipe. I solved that by adding this code:
mRecyclerView.getLayoutManager().setMeasurementCacheEnabled(false);
According to the doc
With the release 23.2.0 there is an exciting new feature to the LayoutManager API: auto-measurement!
This allows aRecyclerView
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"