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

3

我正在使用带有 collapsingToolbarlayoutnestedscrollview 的应用程序,这很好用,直到 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>

我进行了大量搜索,但我不知道为什么会发生这种情况。

谢谢您提前的帮助。

更新

我已经找到了问题所在,我正在包含一个包含horizontalscrollview的布局,当它为空或包含数据时,就会导致此问题,如果有人知道这个问题可以帮助我,谢谢。

1个回答

5
我认为原因是由于偏移导致最后的项目超出了屏幕范围,所以您可以尝试添加以下内容:
android:paddingBottom="<your toolbar height in collapsed state>"

将它添加到你的NestedScrollView中。在我的情况下,这有所帮助。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接