I'm trying to push right an ImageView using a translationX animation on a RadioButton. That's the layout that I've created:
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<RadioButton
android:id="@+id/radio_button"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginStart="10dp"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>
<ImageView
android:id="@+id/image"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="15dp"
android:background="@drawable/my_image"
app:layout_constraintStart_toEndOf="@id/radio_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="8:5"
/>
Which starts like this:
Then I start this animation programmatically:
radioButton.animate().translationX(50).setDuration(500).start();
Expecting something like: (Please note that both width and height has their size reduced in this preview, respecting layout_constraintDimensionRatio="8:5")
But unfortunately only RadioButton translates (and ends behind the image), while ImageView remains the same size and in the same position. Can you help me understand why this happens?
I thought that the key instruction was app:layout_constraintStart_toEndOf="@id/radio_button"
in ImageView, but I think that I'm missing something.
Any help is appreciated, thank you all