0

My recyclerview is showing all items in Android 4-5 but not showing all items in Android 6. I tried to debug it but i did'nt find anything in xml or adpater file. Anyone having same kind issue?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    tools:context="com.app.Activities.ProductActivity"
    android:orientation="vertical">

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:elevation="4dp"
    android:layout_gravity="center"
    android:layout_width="match_parent"
    android:layout_height="56dp"
    android:background="?attr/colorPrimary"
    app:layout_scrollFlags="scroll|enterAlways"
    app:popupTheme="@style/AppTheme.PopupOverlay"
    app:theme="@style/ToolBarStyle"
    android:gravity="center_horizontal"/>


<ScrollView
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center"
    android:layout_weight="1"
    android:fillViewport="true"
    android:fitsSystemWindows="true"
    android:isScrollContainer="true"
    android:scrollbars="none">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="8dp">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/productsRV"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />
    </LinearLayout>
</ScrollView>

enter image description here

DIGITAL JEDI
  • 1,672
  • 3
  • 24
  • 52

3 Answers3

1

Nesting a RecyclerView inside a ScrollView is something that should be done with care.

Try removing the ScrollView and just living the RecyclerView.

Like this

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    tools:context="com.app.Activities.ProductActivity"
    android:orientation="vertical">

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:elevation="4dp"
    android:layout_gravity="center"
    android:layout_width="match_parent"
    android:layout_height="56dp"
    android:background="?attr/colorPrimary"
    app:layout_scrollFlags="scroll|enterAlways"
    app:popupTheme="@style/AppTheme.PopupOverlay"
    app:theme="@style/ToolBarStyle"
    android:gravity="center_horizontal"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="8dp">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/productsRV"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />
    </LinearLayout>

If it doesn't work, post the rest of the code.

Computer's Guy
  • 5,122
  • 8
  • 54
  • 74
1

Try this and it will work for you.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    tools:context="com.app.Activities.ProductActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="8dp">

       <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:elevation="4dp"
        android:layout_gravity="center"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/AppTheme.PopupOverlay"
        app:theme="@style/ToolBarStyle"
        android:gravity="center_horizontal"/>  

        <android.support.v7.widget.RecyclerView
          android:id="@+id/productsRV"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginTop="16dp"
          app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 
     </LinearLayout>
</ScrollView>
Sanjeev Sangral
  • 1,385
  • 2
  • 25
  • 37
0

Thankyou, it started working in Android 6 by replacing scrollview with nested scrollview.

DIGITAL JEDI
  • 1,672
  • 3
  • 24
  • 52