Скрывающийся AppBar при прокрутке списка

У меня есть следующая разметка. Я хочу, чтобы при скролинге списка, из appBar Скрывались элемент categoryContainer(называю его по id). Если я прописываю флаг app:layout_scrollFlags="enterAlways|scroll" для categoryContainer, то ничего не работает, но если я добавляю такой же флаг для searchContainer, то categoryContainer скрывается, но так же скрывается searchContainer, а мне надо скрыть только categoryContainer

<androidx.coordinatorlayout.widget.CoordinatorLayout
        android:id="@+id/contentContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/white"
        android:fitsSystemWindows="true"
        android:visibility="visible">

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

            <LinearLayout
                android:id="@+id/searchContainer"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:orientation="horizontal"
                android:gravity="center_vertical"
                app:layout_scrollFlags="enterAlways|scroll">

                <ImageView
                    android:layout_width="25dp"
                    android:layout_height="25dp"
                    android:src="@drawable/ic_arrow_left"
                    android:layout_marginStart="10dp"
                    android:layout_marginEnd="8dp"
                    app:tint="@color/blackTextPrimary"
                    tools:ignore="ContentDescription" />

                <RelativeLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="@dimen/primary_space">

                    <include layout="@layout/view_search" />

                </RelativeLayout>

            </LinearLayout>

            <LinearLayout
                android:id="@+id/categoryContainer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                app:layout_scrollFlags="enterAlways|scroll">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:gravity="center_vertical"
                    android:paddingStart="@dimen/primary_space"
                    android:paddingEnd="@dimen/primary_space">

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:orientation="vertical"
                        android:gravity="center_vertical">

                        <TextView
                            android:id="@+id/categoryName"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:fontFamily="@font/rotonda_bold"
                            android:maxLines="1"
                            android:textColor="@color/blackTextPrimary"
                            android:textSize="17sp"
                            android:text="Возьми на природу" />

                        <TextView
                            android:id="@+id/productAmount"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:fontFamily="@font/rotondac"
                            android:maxLines="1"
                            android:textColor="@color/blackTextLight"
                            tools:layout_editor_absoluteX="16dp"
                            android:text="452 товара" />

                    </LinearLayout>

                    <ImageView
                        android:id="@+id/share"
                        android:layout_width="25dp"
                        android:layout_height="25dp"
                        android:src="@drawable/ic_share"
                        app:tint="@color/blackTextPrimary"
                        tools:ignore="ContentDescription" />

                </LinearLayout>

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <androidx.cardview.widget.CardView
                        android:layout_width="match_parent"
                        android:layout_height="40dp"
                        android:layout_marginStart="@dimen/primary_space"
                        android:layout_marginEnd="@dimen/primary_space"
                        android:layout_marginTop="8dp"
                        android:layout_marginBottom="4dp"
                        app:cardCornerRadius="5dp"
                        app:cardElevation="1dp">

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:gravity="center_vertical"
                            android:orientation="horizontal">

                            <ImageView
                                android:layout_width="25dp"
                                android:layout_height="25dp"
                                android:src="@drawable/ic_categories"
                                android:layout_marginStart="16dp"
                                app:tint="@color/blackTextLight" />

                            <TextView
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginStart="@dimen/primary_margin"
                                android:fontFamily="@font/rotondac"
                                android:maxLines="1"
                                android:text="Категории"
                                android:textColor="@color/blackTextPrimary"
                                android:textSize="17sp"
                                app:layout_constraintBottom_toBottomOf="parent"
                                app:layout_constraintTop_toBottomOf="@id/categoryName" />

                        </LinearLayout>

                    </androidx.cardview.widget.CardView>

                </RelativeLayout>

            </LinearLayout>

            <LinearLayout
                android:id="@+id/sortContainer"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:orientation="horizontal"
                android:paddingStart="@dimen/primary_space"
                android:paddingEnd="@dimen/primary_space"
                android:gravity="center_vertical">

                <ImageView
                    android:id="@+id/viewMode"
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:src="@drawable/ic_table"
                    app:tint="@color/blackTextPrimary"
                    tools:ignore="ContentDescription" />

                <View
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="match_parent"/>

                <TextView
                    android:id="@+id/sort"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:fontFamily="@font/rotonda_bold"
                    android:textColor="@color/blackTextPrimary"
                    android:drawableEnd="@drawable/ic_arrow_drop_down"
                    android:text="Выбрать сортировку"/>

                <View
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="match_parent"/>

                <ImageView
                    android:id="@+id/filter"
                    android:layout_width="25dp"
                    android:layout_height="25dp"
                    android:src="@drawable/ic_filter"
                    app:tint="@color/blackTextPrimary"
                    tools:ignore="ContentDescription" />

            </LinearLayout>

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

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

    </androidx.coordinatorlayout.widget.CoordinatorLayout>

Ответы (0 шт):