Created
February 24, 2020 18:56
-
-
Save PatrykAndroid/75dcfb8d22f5e41bfef93d2813eef3ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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