Scroll behavior of Flexible Space in Android

半城伤御伤魂 提交于 2019-12-13 09:18:11

问题


To prevent from re-posting all my code again, it can be found in this question.

What I'd like to do now, is to prevent the upper imageview from shrinking upon scrolling; instead, I'd like to make it 'static' so it won't scroll up and shrink when the lower view is scrolled over it.

I'll add some pictures to compensate for the loss of clarification.

This is how the screen looks at it's fullest size:

This is how it looks when it's shrinked:

This is what I want:

Edit: Forgot to mention what I tried and didn't work. Tried playing with the collapseMode of the ImageView which appears not related. Also tried playing with the scrollFlags attribute of the CollapsingToolbarLayout, removing flags and adding enterAlways, but none worked. I have no clue on how to achieve this effect.


回答1:


This simplest way would be to set the parallax multiplier to 1:

<ImageView
    android:id="@+id/backdrop"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="centerCrop"
    android:fitsSystemWindows="true"
    app:layout_collapseMode="parallax"
    app:layout_collapseParallaxMultiplier="1" />


来源:https://stackoverflow.com/questions/33069081/scroll-behavior-of-flexible-space-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!