2

Problem

RecyclerView functions properly and no view is cut when not opening a detailFragment. But it cuts off the last item of my RecylerView item whenever I return back from the detailFragment launched by the recylcerview item.

I only encounter this on my emulator which api 26. When I run it in my api 28 phone it works properly. But I think I might be missing something.

fragment_main

<?xml version="1.0" encoding="utf-8"?>
    <androidx.coordinatorlayout.widget.CoordinatorLayout
            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="match_parent"
            android:fitsSystemWindows="true"
            android:background="@color/colorWhite">

        <com.google.android.material.appbar.AppBarLayout
                android:id="@+id/fragment_main_abl"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:elevation="0dp"
                android:background="@color/colorWhite"
                android:fitsSystemWindows="true">

            <com.google.android.material.appbar.CollapsingToolbarLayout
                    android:id="@+id/fragment_main_ctbl"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:layout_scrollFlags="scroll|exitUntilCollapsed"
                    app:contentScrim="@android:color/white"
                    app:expandedTitleTextAppearance="@color/colorPrimaryText"
                    android:fitsSystemWindows="true">

                <include layout="@layout/header_fragment_main"
                         app:layout_collapseMode="parallax"/>

                <androidx.appcompat.widget.Toolbar
                        android:id="@+id/fragment_main_tb"
                        android:layout_width="match_parent"
                        android:layout_height="?attr/actionBarSize"
                        app:layout_collapseMode="pin">
                </androidx.appcompat.widget.Toolbar>

            </com.google.android.material.appbar.CollapsingToolbarLayout>

            <com.google.android.material.tabs.TabLayout
                    android:id="@+id/fragment_main_tl"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/fragment_main_tl_height"
                    app:tabMode="scrollable"
                    app:tabSelectedTextColor="@color/colorPrimary"
                    app:tabTextColor="@color/colorUnselected"/>

        </com.google.android.material.appbar.AppBarLayout>


        <androidx.viewpager.widget.ViewPager
                android:id="@+id/fragment_main_vp"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
             app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"/>

    </androidx.coordinatorlayout.widget.CoordinatorLayout>

fragment_child

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:background="@android:color/white"
        >

    <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/fragment_child_rv"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:clipToPadding="false"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

NOTE

  • I wish not to put bottom padding for my recyclerView. I have tried this and it works but during the times that my recyclerView functions properly an excess padding is seen at the bottom
  • I wish not to make use of nestedScrollView for my recyclerView if possible since I would like the recyclerView to recycle as much as possible
Asad Ali Choudhry
  • 4,985
  • 4
  • 31
  • 36
  • please read this post [https://stackoverflow.com/questions/56972645/cut-off-items-at-the-bottom-of-the-fragment-page/56984203](https://stackoverflow.com/questions/56972645/cut-off-items-at-the-bottom-of-the-fragment-page/56984203) – user3898288 Jul 14 '19 at 13:08

1 Answers1

1

Replacing

app:layout_scrollFlags="scroll|exitUntilCollapsed"

with

app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed" 

solved my issue.

  • This removes the intended behavior of the toolbar sticking to the top while scrolling. If you want to keep this behavior, add `android:paddingBottom="?attr/actionBarSize"` to your scrolling view instead. – omiwrench May 17 '21 at 15:18