繁体   English   中英

无法使用片段滚动带有 recyclerview 的折叠工具栏

[英]Unable to scroll collapsing toolbar with recyclerview using fragment

我在单个活动中都使用 NavigationView 和 BottomMenu。 在单击底部菜单时使用片段,我正在使用折叠工具栏和 Recyclerview。 当我滚动 recyclerview 时,只有 recyclerview 滚动但折叠工具栏没有折叠。 这是我的代码。 请帮我。

<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:background="#F1F1F1"
android:focusable="true"
android:fitsSystemWindows="true"
android:focusableInTouchMode="true">

<com.google.android.material.appbar.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="180dp"
    android:fitsSystemWindows="true"
    android:background="@android:color/transparent"
    android:theme="@style/AppTheme.AppBarOverlay">

    <com.google.android.material.appbar.CollapsingToolbarLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways|snap">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_scrollFlags="scroll|enterAlways|snap"
            app:layout_collapseMode="parallax">

            <androidx.viewpager.widget.ViewPager
                android:layout_width="match_parent"
                android:layout_height="180dp"
                android:id="@+id/vp_new_banner"/>

            <com.viewpagerindicator.CirclePageIndicator
                android:id="@+id/vp_indicator"
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:layout_marginTop="150dp"
                android:elevation="8dp"
                android:paddingTop="12dp"
                app:centered="true"
                app:fillColor="@color/colorPrimaryDark"
                app:pageColor="#ffffff"
                app:snap="false" />

        </RelativeLayout>

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

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

<include layout="@layout/new_data_2" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

你能把 RecyclerView 在哪里的 xml 代码贴出来吗? 我的猜测是您没有为 RecyclerView 包含app:layout_behavior="@string/appbar_scrolling_view_behavior"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM