Skip to content

Instantly share code, notes, and snippets.

@PatrykAndroid
Created February 24, 2020 18:56
Embed
What would you like to do?
fun animate() {
view2.visibility = View.VISIBLE
val params = ConstraintLayout.LayoutParams(-1, -1)
view2.layoutParams = params
val set = ConstraintSet()
set.connect(view2.id, ConstraintSet.TOP, root.id, ConstraintSet.TOP)
set.connect(view2.id, ConstraintSet.BOTTOM, view1.id, ConstraintSet.BOTTOM)
set.connect(view2.id, ConstraintSet.START, view1.id, ConstraintSet.END)
set.connect(view2.id, ConstraintSet.END, view3.id, ConstraintSet.START)
val transition = AutoTransition()
transition.duration = 1000
TransitionManager.beginDelayedTransition(root, transition)
set.applyTo(root)
}
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/view1"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@color/colorPrimary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/view2"
android:layout_width="1px"
android:layout_height="40dp"
android:background="@color/colorPrimaryDark"
android:visibility="invisible"
app:layout_constraintEnd_toStartOf="@id/view3"
app:layout_constraintStart_toEndOf="@id/view1"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/view3"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@color/colorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment