android:折叠工具栏在向上滚动时反弹

Posted

技术标签:

【中文标题】android:折叠工具栏在向上滚动时反弹【英文标题】:android: collapsing toolbar bounces on scroll up 【发布时间】:2015-10-28 00:14:17 【问题描述】:

我有以下布局

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/rootLayout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:cardview="http://schemas.android.com/apk/res-auto"
    android:background="@color/white"
    android:layout_
    android:layout_>

    <android.support.design.widget.AppBarLayout
        android:fitsSystemWindows="true"
        android:layout_
        android:layout_>

         <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_
            android:layout_
            android:minHeight="?attr/actionBarSize"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            android:fitsSystemWindows="true">

                <RelativeLayout 
                    xmlns:android="http://schemas.android.com/apk/res/android"
                    android:id="@+id/layout_toolbar"
                    android:layout_
                    android:orientation="vertical"
                    app:layout_collapseMode="parallax" 
                    android:layout_>

                        <com.android.volley.toolbox.VolleyImageView 
                            android:id="@+id/image_toolbar"
                            android:layout_
                            android:layout_
                            android:scaleType="centerCrop"/>

                        .... some text views aligned over image...
                </RelativeLayout>

                <android.support.v7.widget.Toolbar
                    android:id="@+id/tool_bar"
                    android:layout_
                    android:layout_
                    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />


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

        <android.support.v7.widget.RecyclerView
        android:id="@+id/list_brands"
        android:layout_
        android:layout_
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>

当我在回收站视图中快速向上滚动时,折叠的工具栏无法顺利打开,而是弹跳并关闭。我不知道怎么了。我正在关注this 文章。

任何帮助将不胜感激。

【问题讨论】:

【参考方案1】:

编辑:更新到 v23 设计和 v23 recyclerview 似乎修复了反弹效果。您还需要将 compileSdkVersion 更改为 23,并将 buildToolsVersion 更改为“23.0.0”。 如果您尝试从标题滚动,请注意 v23 有其他错误,例如崩溃

    at android.support.design.widget.CoordinatorLayout.onTouchEvent(CoordinatorLayout.java:449)

这里有针对这个新错误的不同解决方案https://code.google.com/p/android/issues/detail?id=183166

这是在 google 上跟踪的一个错误,他们说它应该在 com.android.support.design v23 中修复

https://code.google.com/p/android/issues/detail?id=175243

【讨论】:

它似乎没有解决,因为我遇到了同样的问题,而且最新版本的谷歌 IO 应用程序也有这个问题。

以上是关于android:折叠工具栏在向上滚动时反弹的主要内容,如果未能解决你的问题,请参考以下文章

锚定到应用栏的 FAB 不会在向上滚动时隐藏

带有折叠工具栏的Android SlidingTabLayout错误定位

Whatsapp 喜欢折叠工具栏

Android CollapsingToolbarLayout 折叠监听器

在折叠栏布局android中向上滚动时淡化整个布局

带有图像的折叠工具栏中的Android主页按钮