How to make CollapsingToolbarLayout stretching
Asked Answered
B

4

10

I used CollapsingToolbarLayout and i need to make it stretching something like this:

enter image description here

this is my layout:

        <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:collapsedTitleGravity="bottom|center_horizontal"
        app:expandedTitleTextAppearance="@android:color/transparent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
        app:title="@string/app_name">


            <ImageView
                android:id="@+id/coverIv"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:scaleType="fitXY"
                app:layout_collapseMode="parallax" />

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="80dp"
            app:layout_collapseMode="pin"

            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

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

and i need to make the stretching on the imageView. there is any way to do it with CollapsingToolbarLayout? or just with a 3rd party library? I found a way to do it only with 3rd-party (this) but is work with ListView and i have a Recyclerview. but anyway i need to work with android.support.design.widget.CollapsingToolbarLayou.

so there is any chance CollapsingToolbarLayout is supported on something like this? if not, has 3rd party like that are working with actionbar?

Thanks for helping

Berserker answered 11/9, 2017 at 17:40 Comment(2)
#44808707 go to this link, i think your solution is there.Exalt
#44808707 go to this link. you might find solution.Exalt
G
3

You need to use the overscroll distance that is travelled by user once the NestedScrollView has reached the top. Then start to expand the CollapsingToolbar for some value and scale the image inside for the same value.

Here in my blog post I did something similar.

Glare answered 20/9, 2017 at 7:31 Comment(0)
F
2

Ive used this library for similar task and it did the trick.

Flyweight answered 20/9, 2017 at 7:11 Comment(1)
I check this library but isn't work with CollapsingToolbarLayout or with some toolbarBerserker
B
1

try this library it Supports pull-down image of RecyclerView

https://github.com/gatsbydhn/PullToZoomInRecyclerView it has similar functionality to the library that you have mentioned. or you can use this one PullZoomRecyclerView

Badajoz answered 20/9, 2017 at 6:58 Comment(1)
I check these libraries . is make the bounce animation but they don't work with CollapsingToolbarLayout or with some toolbarBerserker
B
0

You can achieve this behavior by extends appbarLayoutBehavior then override onNestedScroll and add the behavior you want.

you can check source code https://android.googlesource.com/platform/frameworks/support/+/refs/heads/master/design/src/android/support/design/widget/AppBarLayout.java

look at snapToChildIfNeeded

Bahner answered 26/9, 2017 at 16:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.