I have an ImageView
above a RecyclerView
and I am trying to find a way to update the ImageView
as I scroll through the RecyclerView where the top item(image) of the RecyclerView is enlarged and displayed on the ImageView while scrolling.
After some digging around, I found that I could use ItemTouchHelper.SimpleCallback
or ItemTouchHelper.Callback
. However, both implement swiping animations that I would not want in my own RecyclerView, or I simply haven't found a way to get rid of these animations.
I hope my explanation was clear enough and if not a comment would be much appreciated.
Here is my xml file for reference:
<layout 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">
<data>
<variable
name="viewModel"
type="com.example.collection.presentation.overview.CollectionOverviewViewModel" />
<variable
name="plantPhoto"
type="com.example.storage.data.PlantPhoto" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true">
<Button
android:id="@+id/to_collection_overview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/collection_overview"
app:layout_constraintBottom_toTopOf="@+id/collection_individual_imageview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.882"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.17000002" />
<ImageView
android:id="@+id/collection_individual_imageview"
android:layout_width="150dp"
android:layout_height="200dp"
android:adjustViewBounds="false"
app:singleImage="@{viewModel.plantPhotoDisplay.plantFilePath}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.26999998"
tools:srcCompat="@tools:sample/avatars" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/collection_individual_recyclerview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/collection_individual_imageview"
app:layout_constraintVertical_bias="0.498"
app:listPhotoData="@{viewModel.listPlantPhoto}"
tools:listitem="@layout/image_plant_photo_view" />
<TextView
android:id="@+id/test_individual"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="Name"
app:layout_constraintBottom_toTopOf="@+id/collection_individual_recyclerview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/collection_individual_imageview" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>