Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BottomSheetBehavior] STATE_HALF_EXPANDED + CollapsingToolbarLayout scrollFlag scroll #489

Open
kibotu opened this issue Aug 2, 2019 · 3 comments

Comments

@kibotu
Copy link

kibotu commented Aug 2, 2019

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

@kibotu kibotu added the bug label Aug 2, 2019
@apuli
Copy link

apuli commented May 5, 2020

@kibotu were you able to solve this? I'm having this same problem now, and can't fix it :(

@kibotu
Copy link
Author

kibotu commented May 5, 2020

not exactly, i kind of ended up manually adding bottom padding to the recyclerview :/ which does not work particularly well with different recyclerview items and / or in case they change height by e.g. collapsing / expanding

@rekire
Copy link

rekire commented Apr 19, 2021

I ran into a similar situation my solution is to use marginButton to the recycler view

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants