0

I have a little problem with Motionlayout. I want to expand img from 0 to for example 350 dp width and 250 dp height on the top of the screen but in the middle horizontal. Now my image is expanding but is doing this from left down side not middle. I would like to start and end expanding in center horizontal. Where is problem?

Here is my scene:

<Transition
    motion:constraintSetEnd="@+id/end"
    motion:constraintSetStart="@id/start"
    motion:autoTransition="animateToEnd"
    motion:duration="1500"
    >

</Transition>

<ConstraintSet android:id="@+id/start">
    <Constraint
        android:id="@+id/imageView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        motion:layout_constraintTop_toTopOf="parent"
        motion:layout_constraintStart_toStartOf="parent"
        motion:layout_constraintRight_toRightOf="parent"
        />

</ConstraintSet>

<ConstraintSet android:id="@+id/end">
    <Constraint
        android:id="@+id/imageView"
        android:layout_width="350dp"
        android:layout_height="250dp"
        motion:layout_constraintTop_toTopOf="parent"
        motion:layout_constraintStart_toStartOf="parent"
        motion:layout_constraintRight_toRightOf="parent"
        />

</ConstraintSet>

Here is foto how it looks in AndroidStudio:

enter image description here

wenus
  • 1,345
  • 6
  • 24
  • 51

1 Answers1

0

android:layout_width="0dp" android:layout_height="0dp" motion:layout_constraintTop_toTopOf="parent" motion:layout_constraintStart_toStartOf="parent" motion:layout_constraintRight_toRightOf="parent"

The constraints have 2 problems:

  1. Hight of 0dp with only one side constrained needs more. (Set bottom, or aspectRatio)
  2. "Start" goes with "end" or "Right" goes with "Left"
hoford
  • 4,918
  • 2
  • 19
  • 19