Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RecyclerView item fills the whole screen

I have a Recyclerview which is working fine with the Android version 23 but if i am running the same code with the Android version 25 then the whole screen is occupied by the single item.

Initially the list looks fine where the item height is wrap content. But as i scroll the whole screen is occupied by single item.

Below is my layout containing RecyclerView:

<LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:orientation="vertical">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/my_recycler_view"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:scrollbars="vertical" />

</LinearLayout>
like image 422
AndroGeek Avatar asked Feb 24 '17 10:02

AndroGeek


2 Answers

Your Recyclerview code is ok. if you are using TextView or else in your iteam_raw.xml then make sure you give "wrap_content"

iteam_raw.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

  <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

</LinearLayout>
like image 162
Mohit Kacha Avatar answered Oct 04 '22 15:10

Mohit Kacha


Please use recyclerview item's main layout height "wrap_content".

like image 40
Lalit Jadav Avatar answered Oct 04 '22 15:10

Lalit Jadav