How to make CollapsingToolbarLayout stretching

I used CollapsingToolbarLayout, and I need to make it stretch 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 stretch the image. is there any way to do this using CollapsingToolbarLayout? or just with a third-party library? I found a way to do this only with a third-party (this) , but it works with ListView, and I have Recyclerview. but anyway I need to work with android.support.design.widget.CollapsingToolbarLayou.

so is there a chance that CollapsingToolbarLayout is supported on something like this? if not, is there a 3rd party who works with the action bar?

thanks for the help

+8
android android-actionbar android-toolbar android-collapsingtoolbar
source share
4 answers

You need to use the scroll distance that the user moves as soon as the NestedScrollView reaches the top. Then start CollapsingToolbar for some value and scale the image inside for the same value.

Here in my blog post I did something similar.

+3
source share

try this library. Supports RecyclerView Dropdown

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

+2
source share

I used this library for a similar task, and it did the trick.

+2
source share

You can achieve this by extending appbarLayoutBehavior, then override onNestedScroll and add the desired behavior.

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

look at snapToChildIfNeeded

0
source share

All Articles