I have a child view that is constraint to another child view as you can see in the below example code
<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">
<TextView
android:id="@+id/main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Main"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Second"
app:layout_constraintBottom_toBottomOf="@id/main"
app:layout_constraintEnd_toStartOf="@id/main"
app:layout_constraintTop_toTopOf="@id/main" />
<Button
android:id="@+id/start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="start"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
When I animate/move the main
TextView
, I am expecting that the secondary
view should move with it since it is constraint to its top, bottom and start.
The main
view is moved using a simple translate animation of the Y position.
So the question is why the secondary
TextView
not moving?