为什么当 CollapsingToolbarLayout 完全折叠时 NestedScrollView 停止滚动?

2023-12-12

我在用collapsingToolbarlayout with nestedscrollview它工作正常,直到collapsingToolbarlayout完全崩溃了并且actionbar正在显示。这里的nestedscrollview停止滚动,一些项目仍然隐藏。

这是我的 xml 文件

    <android.support.design.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.support.design.widget.AppBarLayout
        android:id="@+id/app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        >

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginStart="48dp"
            app:expandedTitleMarginEnd="64dp"
            >

            <FrameLayout
                android:id="@+id/topLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fitsSystemWindows="true"
                app:layout_collapseMode="parallax"
                >

                <ImageView
                    android:id="@+id/BigThumbnailImage"
                    android:layout_width="match_parent"
                    android:layout_height="200dp"
                    android:adjustViewBounds="true"
                    android:fitsSystemWindows="true"
                    android:src="@drawable/bg_health_news"
                    android:scaleType="fitXY" />

            </FrameLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:layout_collapseMode="pin" />

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/scroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:weightSum="1"
            >

            <include
                android:layout_width="match_parent"
                android:layout_height="0dp"
                layout="@layout/place_item_details_views"
                android:layout_weight="1"
                />

        </LinearLayout>

    </android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>

我已经搜索了很多,但我不知道为什么会发生这种情况

提前致谢

UPDATE

我发现问题是我包含的布局包含horizontalscrollview当它为空或包含数据时,它会导致此问题,如果有人知道这个问题可以帮助我,谢谢


我认为原因是你的最后一个项目由于班次而超出了屏幕,所以你可以尝试添加:

android:paddingBottom="<your toolbar height in collapsed state>"

到您的 NestedScrollView。就我而言,这很有帮助。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为什么当 CollapsingToolbarLayout 完全折叠时 NestedScrollView 停止滚动? 的相关文章

随机推荐