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