I want to have an initial state where the header is 140dp above the recycler view.
When the user scrolls up, the header shrinks to 65dp
When the user scrolls down, the header expands to 170dp
The approach:
I have my layout as below
<androidx.constraintlayout.motion.widget.MotionLayout 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:id="@+id/motion"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="@xml/sample_collapsing_animation_scene">
// something on top of the guideline
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline_toolbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="140dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/scrollable_content"
android:layout_width="0dp"
android:layout_height="0dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/guideline_toolbar"
tools:listitem="@layout/dummy_list_item"/>
</androidx.constraintlayout.motion.widget.MotionLayout>
When the user scrolls down recycler view, nothing happens
When the user scrolls up, the header expands when it should collapse.
If I remove the first transition, the header collapse when the user scrolls up as expected.
If I replace the recycler view with a regular View, the code works as expected.
I guess the reason may be due to the recyclerview is scrollable?
The problem:
I want to have an initial state where the header is 140dp above the recycler view. When the user scrolls up, the header shrinks to 65dp When the user scrolls down, the header expands to 170dp
The approach:
I have my layout as below
and here is my motion scene
The unexpected behavior:
When the user scrolls down recycler view, nothing happens When the user scrolls up, the header expands when it should collapse. If I remove the first transition, the header collapse when the user scrolls up as expected. If I replace the recycler view with a regular View, the code works as expected.
I guess the reason may be due to the recyclerview is scrollable?