I tried to replicate this behaviour, but after implementing it I observed a large performance decrease.
Then I tried to implement it in a different way: I would put the image behind the scrollview, and simply give the contents of the scrollview some top padding. Here's some relevant XML:
<android.support.constraint.ConstraintLayout 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"
tools:context="">
<ImageView
android:id="@+id/profileImage"
android:layout_width="0dp"
android:layout_height="144dp"
android:scaleType="centerCrop"
android:src="@drawable/mapview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ScrollView
android:id="@+id/profileScrollView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:paddingBottom="70dp"
android:paddingTop="120dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
</android.support.constraint.ConstraintLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
I left out unnecessary XML.
This poor performance happens when the ScrollView tries to move over an ImageView. It still happens if the ImageView is embedded in another view, like a ConstraintLayout.
Why is this ScrollView slow? Am I supposed to change something in my layout? Thanks!