You can customize the parallax animation by tracking the scrolling view of the Recycler
Firstly, in the image view layout. Set the parent layout smaller than the image view to prevent the image outside the frame when setting the translation
<android.support.percent.PercentRelativeLayout android:id="@+id/index_level6_image_section" android:layout_width="match_parent" android:layout_height="200dp" android:clipChildren="false"> <ImageView android:id="@+id/index_level6_parallaxImage" android:layout_width="match_parent" android:layout_height="240dp" android:layout_centerInParent="true" android:background="@color/timberwolf" android:layout_marginTop="-20" android:layout_marginBottom="-20" android:scaleType="centerCrop" app:imageUrl="@{level6CellViewModel.level6ImageUrl}" /> </android.support.percent.PercentRelativeLayout>
After that, track the scrolling effect of the recycler view and the transition to the image.
*** I am using rxbinding and kotlin for implementation. You can use the traditional listening method and java approach with the same idea.
RxRecyclerView.scrollEvents(recyclerView) .subscribe { event ->
Kit Nov 04 '16 at 4:14 2016-11-04 04:14
source share