material-components / material-components/material-components-android

[BottomSheetBehavior] STATE_HALF_EXPANDED + CollapsingToolbarLayout scrollFlag scroll

Open
#489 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Widget: BottomSheet Widget: TopAppBar
Dominant language
Java
Stars
17.4k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

Description:

When BottomSheetBehavior is in STATE_HALF_EXPANDED and AppBarLayout/CollapsingToolbarLayout has layout_scrollFlags="scroll", the bottom sheet won't scroll up / expand the bottom sheet view when RecyclerView has reached its end when the CollapsingToolbarLayout has expanded its content. (everything works fine if BottomSheetBehavior expanded or peek height)

Also RecyclerView has not correct size at the end. e.g. only 27 / 30 items would be possible to scroll up. looks like the RecyclerView has the wrong size or is not full scrolled up

Looks like the RecyclerView consumes all scrolling events, because touching the expanded CollapsingToolbarLayout view scrolls the BottomSheetBehavior view successfully up.

Expected behavior:

While the BottomSheetBehavior is in STATE_HALF_EXPANDED and the user scrolls up, the RecyclerView should scroll the last item into visible view port and after that the bottom sheet should expand. (which it does unless there is a scroll flag set)

Source code:

 <?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/coordinator"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <!--  content  -->

    </androidx.constraintlayout.widget.ConstraintLayout>

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:id="@+id/bottom_sheet"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        app:behavior_fitToContents="false"
        app:behavior_hideable="false"
        app:behavior_peekHeight="78dp"
        app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
        tools:behavior_peekHeight="400dp">

        <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/color_background"
            app:expanded="true">

            <com.google.android.material.appbar.CollapsingToolbarLayout
                android:id="@+id/collapsingToolbarLayout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:minWidth="32dp"
                app:layout_scrollFlags="scroll|exitUntilCollapsed|enterAlways|snap">

                <com.google.android.material.card.MaterialCardView
                    android:id="@+id/tabCard"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="@dimen/keyline_4"
                    app:cardBackgroundColor="@android:color/transparent">

                    <com.google.android.material.tabs.TabLayout
                        android:id="@+id/show_tabs"
                        android:layout_width="match_parent"
                        android:layout_height="32dp"
                        android:background="@drawable/tab_layout_background"
                        app:layout_collapseMode="parallax"
                        app:tabBackground="@drawable/selector_tab_rounded_corner"
                        app:tabIndicatorHeight="0dp"
                        app:tabSelectedTextColor="?colorOnPrimary"
                        app:tabTextAppearance="?textAppearanceBody2"
                        app:tabTextColor="?colorOnSurface">

                        <com.google.android.material.tabs.TabItem
                            android:id="@+id/nextShowTab"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            tools:text="Tab 1" />

                        <com.google.android.material.tabs.TabItem
                            android:id="@+id/distanceTab"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            tools:text="Tab 2" />

                    </com.google.android.material.tabs.TabLayout>

                </com.google.android.material.card.MaterialCardView>

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

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

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/filterResultList"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/color_background"
            android:clipToPadding="false"
            android:descendantFocusability="afterDescendants"
            app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            tools:background="@color/md_red_200"
            tools:itemCount="10" />

    </androidx.coordinatorlayout.widget.CoordinatorLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout> 

Android API version: 29

Material Library version: com.google.android.material:material:1.1.0-alpha08

Device: Samsung Galaxy S9

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied CoordinatorLayout XML and reproduce the behavior using BottomSheetBehavior in STATE_HALF_EXPANDED, AppBarLayout/CollapsingToolbarLayout with the listed scroll flags, and the RecyclerView. Check how scrolling is coordinated when the RecyclerView reaches its end and the CollapsingToolbarLayout is expanded. Done means the last RecyclerView item is reachable and continued upward scrolling expands the bottom sheet.

Written by the indexing model from the issue text.

Assessment

Tech stack
android
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.