简体   繁体   English

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

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

i am using NavigationView and BottomMenu both in single activity.我在单个活动中都使用 NavigationView 和 BottomMenu。 Using fragment on clicking of bottom menu i am using Collapsing Toolbar and Recyclerview.在单击底部菜单时使用片段,我正在使用折叠工具栏和 Recyclerview。 When i scroll recyclerview only recyclerview scroll but collapsing toolbar is not collapsed.当我滚动 recyclerview 时,只有 recyclerview 滚动但折叠工具栏没有折叠。 Here is my code.这是我的代码。 Please help me.请帮我。

<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>

Can you post the xml code of where the RecyclerView is?你能把 RecyclerView 在哪里的 xml 代码贴出来吗? My guess is you didn't include app:layout_behavior="@string/appbar_scrolling_view_behavior" for the RecyclerView.我的猜测是您没有为 RecyclerView 包含app:layout_behavior="@string/appbar_scrolling_view_behavior"

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

相关问题 如何同时滚动折叠工具栏和RecyclerView? - How to scroll collapsing Toolbar and RecyclerView simultaneously? 折叠工具栏不会与 RecyclerView 折叠 - Collapsing Toolbar not collapsing with RecyclerView 在片段内而不是活动内使用recyclerview时,在滚动条上隐藏工具栏 - Hide toolbar on scroll when the using a recyclerview inside a Fragment instead of an Activity 无法滚动AppBarLayout并平滑地折叠工具栏和NestedScrollView - Unable to scroll AppBarLayout and collapsing toolbar with NestedScrollView smoothly 隐藏工具栏滚动与片段内的recyclerview - Hiding Toolbar on scroll with recyclerview inside fragment 工具栏不会与嵌套的RecyclerView折叠 - Toolbar not collapsing with nested RecyclerView 带有折叠工具栏的RecyclerView和ViewPager - RecyclerView and ViewPager with collapsing toolbar RecyclerView不会在折叠工具栏中滚动 - RecyclerView not scrolling in Collapsing Toolbar 如何停止“折叠工具栏”滚动取决于RecyclerView列表计数 - How to stop the Collapsing ToolBar scroll depends on RecyclerView list count 折叠工具栏图像在recyclerview的状态栏下方滚动 - Collapsing Toolbar Image coming under status bar on recyclerview scroll down
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM