I'm new at android app development and trying to get the image scalling animation/effect based on the direction of the scroll like in this video.Please provide kotlin code if needed.Thanks in advance[Here is the effect I want:](https://i.stack.imgur.com/XFEhv.gif)
Here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/black">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsingToolbarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="@color/transparent"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed">
<ImageView
android:id="@+id/scrollingImageView"
android:layout_width="match_parent"
android:layout_height="360dp"
android:alpha="0.7"
android:src="@drawable/live_events_category_img"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="@color/transparent"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="1"
app:layout_scrollFlags="exitUntilCollapsed">
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="@color/black"
android:isScrollContainer="true"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
After long research I figure out that we can achieve this effect by calling addOnOffsetChangedListener on the appBarLayout which will give us the offset value for each scrollposition based on which we can perform calculation on scaling parameter of the imageview as need. Here is what I added in the kotlin file whereas the xml remain the same: