Skip to content

Instantly share code, notes, and snippets.

@kmshack
Created May 31, 2017 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmshack/f733c0881e01eb71eb7ad122376281cd to your computer and use it in GitHub Desktop.
Save kmshack/f733c0881e01eb71eb7ad122376281cd to your computer and use it in GitHub Desktop.
main.kt
override fun onCreate(savedInstanceState: Bundle?) {
...
val constraintSet1 = ConstraintSet()
constraintSet1.clone(constraintLayout)
val constraintSet2 = ConstraintSet()
constraintSet2.clone(this, R.layout.activity_main_alt)
var changed = false
findViewById(R.id.button).setOnClickListener {
TransitionManager.beginDelayedTransition(constraintLayout)
val constraint = if (changed) constraintSet1 else constraintSet2
constraint.applyTo(constraintLayout)
changed = !changed
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment