Skip to content

Instantly share code, notes, and snippets.

@vorobeij
Created August 9, 2018 12:51
Show Gist options
  • Save vorobeij/b8620cdd68cc93b0de441ca190c2eded to your computer and use it in GitHub Desktop.
Save vorobeij/b8620cdd68cc93b0de441ca190c2eded to your computer and use it in GitHub Desktop.
ConstraintLayout transition animations
private val transition = AutoTransition().apply {
duration = 250
interpolator = AccelerateInterpolator()
}
private var cs = ConstraintSet()
override fun showSearchEngineIcon() {
cs.clone(searchViewConstraintLayout)
cs.connect(searchView.id, ConstraintSet.START, searchEngineIconImageView.id, ConstraintSet.END)
cs.setAlpha(searchEngineIconImageView.id, 1F)
TransitionManager.beginDelayedTransition(searchViewConstraintLayout, transition)
cs.applyTo(searchViewConstraintLayout)
}
override fun hideSearchEngineIcon() {
cs.clone(searchViewConstraintLayout)
cs.connect(searchView.id, ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START)
cs.setAlpha(searchEngineIconImageView.id, 0F)
TransitionManager.beginDelayedTransition(searchViewConstraintLayout, transition)
cs.applyTo(searchViewConstraintLayout)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment