-1

I’ve faced an issue regarding to unexpected animating the recyclerview when scrolling it to horizontal direction. The recycler view is inside of NestedScrollView and the NestedScrollView is inside of MotionLayout. I’ve spent a couple of days to find the cause without any success, please help

https://youtu.be/NkYs9BtJjNo

<?xml version="1.0" encoding="utf-8"?>
<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.aaa.viewModel.preview.PreviewVM" />
   </data>
   <androidx.constraintlayout.motion.widget.MotionLayout
       android:id="@+id/motionLayout"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:background="@color/gray_3"
       android:clickable="true"
       android:focusable="true"
       app:layoutDescription="@xml/motion_scene"
       app:showPaths="false">
       <ImageView
           android:id="@+id/imageContainer"
           android:layout_width="@dimen/_85sdp"
           android:layout_height="@dimen/_85sdp"
           android:layout_gravity="center"
           android:layout_marginStart="@dimen/_8sdp"
           android:layout_marginTop="@dimen/_4sdp"
           android:contentDescription="@string/todo"
           android:scaleType="centerCrop"
           app:layout_constraintStart_toStartOf="parent"
           app:layout_constraintTop_toTopOf="parent"
           app:src="@{viewModel.itemAlbum.avatarUrl}" />
       <RelativeLayout
           android:id="@+id/container"
           android:layout_width="0dp"
           android:layout_height="@dimen/_100sdp"
           android:layout_marginStart="@dimen/_8sdp"
           android:layout_marginEnd="@dimen/_8sdp"
           app:layout_constraintBottom_toTopOf="@+id/space"
           app:layout_constraintEnd_toEndOf="parent"
           app:layout_constraintStart_toEndOf="@+id/imageContainer">
           <TextView
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:layout_marginTop="@dimen/_12sdp"
               android:ellipsize="marquee"
               android:fontFamily="@font/gotham_book"
               android:marqueeRepeatLimit="marquee_forever"
               android:scrollHorizontally="true"
               android:singleLine="true"
               android:text="Title"
               android:textColor="@color/FC_BACKGROUND_COLOR"
               android:textSize="@dimen/_13sdp"
               tools:text="Cantigo" />
           <Button
               android:layout_width="match_parent"
               android:layout_height="@dimen/_30sdp"
               android:layout_alignParentBottom="true"
               android:background="@drawable/rounded_black_5_sdp"
               android:backgroundTint="@color/FC_SECONDARY_COLOR"
               android:fontFamily="@font/gotham_bold"
               android:gravity="center"
               android:text="Button"
               android:textColor="@color/black"
               android:textSize="@dimen/_12sdp" />
       </RelativeLayout>
       <androidx.core.widget.NestedScrollView
           android:id="@+id/nestedScrollView"
           android:layout_width="0dp"
           android:layout_height="0dp"
           android:layout_marginTop="@dimen/_4sdp"
           app:layout_constraintBottom_toBottomOf="parent"
           app:layout_constraintEnd_toEndOf="parent"
           app:layout_constraintStart_toStartOf="parent"
           app:layout_constraintTop_toBottomOf="@+id/imageContainer">
           <androidx.appcompat.widget.LinearLayoutCompat
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:animateLayoutChanges="true"
               android:orientation="vertical">
               <View
                   android:id="@+id/adView"
                   android:layout_width="300dp"
                   android:layout_height="250dp"
                   android:layout_gravity="center"
                   android:layout_marginTop="@dimen/_18sdp"
                   android:layout_marginBottom="@dimen/_14sdp"
                   android:background="@color/coin_tutorial_bg" />
               <androidx.recyclerview.widget.RecyclerView
                   android:id="@+id/rvArtistAlbum"
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_below="@+id/tvAlbum"
                   android:layout_marginTop="@dimen/_5sdp"
                   android:background="@color/app_background"
                   android:nestedScrollingEnabled="false"
                   android:orientation="horizontal"
                   app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
               <androidx.recyclerview.widget.RecyclerView
                   android:id="@+id/rvArtist"
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_below="@+id/tvAlbum"
                   android:layout_marginTop="@dimen/_25sdp"
                   android:background="@color/app_background"
                   android:nestedScrollingEnabled="false"
                   android:orientation="horizontal"
                   app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
           </androidx.appcompat.widget.LinearLayoutCompat>
       </androidx.core.widget.NestedScrollView>
       <Space
           android:id="@+id/space"
           android:layout_width="0dp"
           android:layout_height="@dimen/_8sdp"
           app:layout_constraintEnd_toEndOf="@+id/imageContainer"
           app:layout_constraintStart_toEndOf="@+id/imageContainer"
           app:layout_constraintStart_toStartOf="@+id/imageContainer"
           app:layout_constraintTop_toBottomOf="@id/imageContainer" />
   </androidx.constraintlayout.motion.widget.MotionLayout>
</layout>

  • 1
    Can you please elaborate a bit more what you want to achieve here? – Prateek Bhandari Aug 25 '20 at 07:58
  • 1
    You have to use NestedScrollView separately, When you are scrolling Recycler view then there is some motion happening in your layout. – DeePanShu Aug 25 '20 at 08:16
  • @PrateekBhandari please watch the video https://youtu.be/NkYs9BtJjNo parent layout (Motionlayout) is jumping after horizontal scroll recyclerview – Rub HHH Aug 25 '20 at 12:56

1 Answers1

0

I think you do not want you swipe and nestedScrollView (RecyclerView) to interact in you add

motion:nestedScrollFlags = "disableScroll"

hoford
  • 2,960
  • 1
  • 12
  • 12