I'm using nested RecycleViews to reproduce the way Google's inbox looks. Now, my problem is that whenever I try to scroll through the items, it seems to get "stuck" after a while:
The data is already loaded and it's rather "static" (it comes from a local db and it's loaded in a property of the main activity - the images are the only things which are retrieved dynamically and I'm using Picasso for that).
I'm already sharing view pools between nested recycler views...I've also tried removing the images, but I still don't have smooth scrolling...
Here's my main layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:background="#FFE7E8ED">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:titleTextColor="@color/colorWhite" />
<!-- forcing focus due neste layout -->
<!-- https://stackoverflow.com/questions/36923948/recycleview-steals-focus-when-inside-a-nestedscrollview?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa -->
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
android:paddingTop="?android:attr/actionBarSize">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swiper"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/lista"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbarSize="4dp"
android:scrollbarThumbVertical="@color/lightgray"
android:scrollbars="vertical">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.constraint.ConstraintLayout>
</FrameLayout>
<!-- Container for contents of drawer - use NavigationView to make configuration easier -->
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/drawer_header"
app:menu="@menu/drawer_viewer" />
</android.support.v4.widget.DrawerLayout>
And here's the layout of the recyclerview's item:
<?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"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/catalog_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="18dp"
android:layout_marginRight="8dp"
android:layout_marginTop="10dp"
android:textAlignment="inherit"
android:textAppearance="@android:style/TextAppearance.Material.WindowTitle"
android:textColor="@android:color/darker_gray"
android:textSize="16sp"
android:textStyle="bold" />
<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:cardElevation="4dp">
<android.support.v7.widget.RecyclerView
android:id="@+id/lista_noticias"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:clipToPadding="false"></android.support.v7.widget.RecyclerView>
</android.support.v7.widget.CardView>
</LinearLayout>
And finally, the layout of the internal recyclerview's item:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="140dp"
android:maxHeight="140dp"
android:minHeight="140dp"
card_view:cardCornerRadius="0dp"
card_view:contentPadding="2dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/logo"
android:layout_width="73dp"
android:layout_height="73dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:adjustViewBounds="false"
android:scaleType="fitXY"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintTop_toTopOf="parent"
card_view:srcCompat="@mipmap/ic_launcher" />
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:lines="1"
android:textAppearance="@android:style/TextAppearance.Material.Title"
android:textSize="16sp"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintStart_toEndOf="@+id/logo"
card_view:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/description"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="@id/title"
android:layout_marginBottom="32dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:ellipsize="end"
android:gravity="top|center_vertical"
android:lines="3"
android:text="Name"
android:textAppearance="@android:style/TextAppearance.Material.SearchResult.Subtitle"
card_view:layout_constraintBottom_toBottomOf="parent"
card_view:layout_constraintEnd_toEndOf="parent"
card_view:layout_constraintStart_toEndOf="@+id/logo"
card_view:layout_constraintTop_toBottomOf="@+id/title"
card_view:layout_constraintVertical_chainStyle="spread_inside" />
<TextView
android:id="@+id/publishDate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:text="10/10/2018 13:50"
android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textSize="10sp"
card_view:layout_constraintBottom_toBottomOf="parent"
card_view:layout_constraintEnd_toEndOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
Can someone please tell me what I'm missing?
thanks.