Large Gap Forms Between Recyclerview Items When Scrolling Down
Solution 1:
Luksprog's answer to Gabriele Mariotti's answer works.
According to the doc
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.
In your item layout you have to change:
android:layout_height="match_parent"
with
android:layout_height="wrap_content"
Solution 2:
change in Recycler view match_parent to wrap_content:
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Also change in item layout xml
Make parent layout height match_parent to wrap_content
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="wrap_content"><TextViewandroid:id="@+id/textView"android:layout_width="wrap_content"android:layout_height="wrap_content"
/>
Solution 3:
This happened to me many times!
All you need to do is... make layout_height of row file wrap_content and your problem solved..
android:layout_height="wrap_content"
Happy coding!
Solution 4:
Its because you are using match_parent in height of root view of the row item in your vertically oriented listview/recyclerview. When you use that the item expands completely wrt to its parent. Use wrap_content for height when the recyclerview is vertically oriented and for width when it is horizantally oriented.
Solution 5:
Avoid taking the view in item layout with a container like this:
<?xml version="1.0" encoding="utf-8"?><layoutxmlns:android="http://schemas.android.com/apk/res/android"><data/><android.support.constraint.ConstraintLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"><TextViewandroid:id="@+id/text"android:layout_width="match_parent"android:layout_height="wrap_content"android:minHeight="?android:listPreferredItemHeight"android:textAppearance="?android:attr/textAppearanceMedium" /></android.support.constraint.ConstraintLayout></layout>
as in this case match_parent
will do its work and the problem will still remain! Rather take it like this:
<?xml version="1.0" encoding="utf-8"?><layoutxmlns:android="http://schemas.android.com/apk/res/android"><data/><TextViewandroid:id="@+id/text"android:layout_width="match_parent"android:layout_height="wrap_content"android:minHeight="?android:listPreferredItemHeight"android:textAppearance="?android:attr/textAppearanceMedium" /></layout>
[Note: Above code has data binding attached to it, don't use <layout>
& <data>
tags if not using data binding]
Other than this, if you must use any view group containers, than take a look the height and width attributes in the container, and try change those from match_parent
to wrap_content
. That should resolve the issue. For more transparency, one can try giving background colours and see through it to identify actual problem.
Post a Comment for "Large Gap Forms Between Recyclerview Items When Scrolling Down"