I have image at the top of my layout and below Imageview I have Recyclerview (Android App,Java,XML)
basically I want the RecyclerView to be positioned below the ImageView and have it scroll up to overlap or collapse the ImageView as the user scrolls up recyclerview
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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=".MainActivity">
<!-- I want the RecyclerView to be positioned below the ImageView and have it scroll up to overlap the ImageView as the user scrolls up recyclerview-->
<ImageView
android:id="@+id/imageView2"
android:layout_width="414dp"
android:layout_height="357dp"
android:src="@drawable/thirdimage"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:layout_width="408dp"
android:layout_height="561dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView2" />
</androidx.constraintlayout.widget.ConstraintLayout>
when I scroll the recyclerview it basically scrolling in it's own space instead of scrolling up taking the space of imageview
You might need to consider using
CoordinatorLayoutwithCollapsingToolbarLayoutto achieve this. I have implemented something similar to what you're asking in one of my project.Here's a quick example.
Don't forget to add
app:layout_collapseMode="parallax"in the ImageView and scroll behavior in the RecyclerView asapp:layout_behavior="@string/appbar_scrolling_view_behavior". Without these properties, you won't be able to see that collapsible scrolling effect.Something similar that I've added:
you can find this here: https://github.com/vishalnaikawadi/TheSchoolOfRock