Created
August 9, 2018 12:51
-
-
Save vorobeij/b8620cdd68cc93b0de441ca190c2eded to your computer and use it in GitHub Desktop.
ConstraintLayout transition animations
This file contains hidden or 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
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