CollapsingToolbarLayout 中使用的 layout_collapseParallaxMultiplier 是什么?

What is layout_collapseParallaxMultiplier used in CollapsingToolbarLayout?

CollapsingToolbarLayout 中使用的 layout_collapseParallaxMultiplier 是什么?

我看过android developer doc,但是没看懂

请举例说明此参数及其与 layout_collapseMode 一起使用时的效果。

下面是xml的简单例子。

<android.support.design.widget.CollapsingToolbarLayout ... >
<ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:src="@drawable/random_pattern"
        android:scaleType="fitXY"
        app:layout_collapseMode="parallax"
        app:layout_collapseParallaxMultiplier="0.75"/>
 </android.support.design.widget.CollapsingToolbarLayout>

这在 Android Design Support Library 上有解释:

In addition to pinning a view, you can use app:layout_collapseMode="parallax" (and optionally app:layout_collapseParallaxMultiplier="0.7" to set the parallax multiplier) to implement parallax scrolling (say of a sibling ImageView within the CollapsingToolbarLayout). This use case pairs nicely with the app:contentScrim="?attr/colorPrimary" attribute for CollapsingToolbarLayout, adding a full bleed scrim when the view is collapsed.

当您使用 app:layout_collapseMode="parallax" 时,这是 a behavior example

用非常简单的话来说:

滚动时我们看到以下内容 - 应用栏图像开始隐藏在内容下方并超出屏幕的上边缘。 参数 layout_collapseParallaxMultiplier 确定图像的哪一部分(百分比)将隐藏在底部内容下。

因此,例如,将此参数设置为值1.0意味着应用栏图像的上边界绑定到屏幕的上边缘并且在滚动时不会移动。主要内容在图像的顶部移动。

不设置参数时对应0.5,图片上下同步叠加