Category : android-motionlayout

Any ideas how to implement scrollToPosition with MotionLayout? Currently I have a RecyclerView and some header that hides on scroll and shows if you scroll to top. This is the scene: <Transition motion:constraintSetEnd="@+id/end" motion:constraintSetStart="@id/start" motion:duration="1000"> <OnSwipe motion:touchAnchorId="@+id/header" motion:dragDirection="dragUp" motion:onTouchUp="stop" /> </Transition> <ConstraintSet android:id="@+id/start"> <Constraint android:id="@+id/header" android:layout_width="0dp" android:layout_height="wrap_content" android:visibility="visible" motion:layout_constraintEnd_toEndOf="parent" motion:layout_constraintStart_toStartOf="parent" motion:layout_constraintTop_toBottomOf="@id/toolbar" /> <Constraint android:id="@+id/recycler_view" android:layout_width="0dp" ..

Read more

I am trying to implement animation using Motion layout. Agenda: On scrolling recycler view or scroll view, custom view should collapse and show only required end layout. start layout end layout end layout activity_main_start.xml <?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"> <RelativeLayout android:id="@+id/topLayout" android:layout_width="0dp" android:layout_height="wrap_content" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> <TextView android:id="@+id/assetValue" android:layout_width="wrap_content" android:layout_height="wrap_content" ..

Read more

I use MotionLayout for the animate view1. I want programmatically change constraint view1 to view2. I want to use different layout’s in my scene instead of using ConstrainsSet So, I have: res/xml/activity_scene.xml <Transition android:id="@+id/transition1" motion:constraintSetStart="@layout/activity_state1" motion:constraintSetEnd="@layout/activity_state2"> // <..> </Transition> res/layout/activity_state1.xml <androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/motionLayout" android:layout_width="match_parent" android:layout_height="match_parent" app:layoutDescription="@xml/activity_scene"> // viev1 is small and view1 at left ..

Read more

I have a motionlayout with a card that scales on swiped. But in some cases a textview with long text is scaled incorrect and change the number of lines. How it looks: https://youtu.be/SOAf8Zpa2Hk My Transotion and ConstraintSet: <Transition android:id="@+id/start_to_missed" motion:constraintSetEnd="@id/missed" motion:constraintSetStart="@id/start" motion:duration="300"> <OnSwipe motion:dragDirection="dragRight" motion:onTouchUp="autoComplete" motion:dragScale="5.0" motion:dragThreshold="0.9" motion:touchAnchorSide="right" motion:maxVelocity="20" motion:maxAcceleration="40" motion:touchRegionId="@id/word_card" /> </Transition> <ConstraintSet android:id="@+id/missed"> ..

Read more

MotionLayout: <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:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" app:layoutDescription="@xml/activity_main_scene"> <FrameLayout android:id="@+id/left_content" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#0c0" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:text="right text" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left" android:text="left text" android:textColor="#33691E" /> </FrameLayout> <FrameLayout android:id="@+id/bar" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="#c00" tools:ignore="SpeakableTextPresentCheck" tools:layout_editor_absoluteX="918dp"> <View android:layout_width="50dp" android:layout_height="match_parent" android:clickable="false" /> </FrameLayout> <FrameLayout android:id="@+id/right_content" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="#00c" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#fff" android:layout_gravity="right" ..

Read more

I am creating animation in splashScreen with motionLayout. But my animation doesn’t work, instead it immediatly shows the ending positions of the elements on the screen. Here is my code: SplashActivity: class SplashActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_splash) motionLayout.transitionToEnd() val handler = Handler() handler.postDelayed( { startActivity(Intent(this, MainActivity::class.java)) finish() }, 3000) ..

Read more