Skip to content

Instantly share code, notes, and snippets.

@mustafayigitt
Created August 8, 2020 14:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mustafayigitt/6c7ab845b36aad2082827a8b249ad6e0 to your computer and use it in GitHub Desktop.
Recyclerview Swipe Animation with MotionLayout
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetEnd="@+id/end"
motion:constraintSetStart="@id/start"
motion:duration="1000">
<KeyFrameSet></KeyFrameSet>
<OnSwipe motion:touchAnchorId="@+id/frameLayout" />
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/txtUserDetailUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toBottomOf="@+id/imgUserDetailPhoto"
motion:layout_editor_absoluteY="150dp" />
<Constraint
android:id="@+id/txtUserDetailUserBio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toBottomOf="@+id/txtUserDetailUsername" />
<Constraint
android:id="@+id/materialTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toEndOf="@+id/imgUserDetailPhoto"
motion:layout_constraintTop_toTopOf="parent" />
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@+id/txtUserDetailUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="0dp"
motion:layout_constraintBottom_toBottomOf="@+id/imgUserDetailPhoto"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="@+id/imgUserDetailPhoto" />
<Constraint
android:id="@+id/txtUserDetailUserBio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
motion:layout_constraintTop_toBottomOf="@+id/txtUserDetailUsername" />
<Constraint
android:id="@+id/imgUserDetailPhoto"
android:layout_width="50dp"
android:layout_height="50dp"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
<Constraint
android:id="@+id/frameLayout"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toBottomOf="@+id/txtUserDetailUserBio" />
<Constraint
android:id="@+id/materialTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
motion:layout_constraintBottom_toBottomOf="@+id/imgUserDetailPhoto"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toEndOf="@+id/imgUserDetailPhoto"
motion:layout_constraintTop_toTopOf="@+id/imgUserDetailPhoto" />
</ConstraintSet>
</MotionScene>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment