Skip to content

Instantly share code, notes, and snippets.

@Stickerbox
Created December 6, 2017 14:08
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 Stickerbox/dc5c7632bd54d5b394e4f5145a1c4238 to your computer and use it in GitHub Desktop.
Save Stickerbox/dc5c7632bd54d5b394e4f5145a1c4238 to your computer and use it in GitHub Desktop.
class MainActivity : AppCompatActivity() {
var hasAnimated = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
override fun onTouchEvent(event: MotionEvent?): Boolean {
if (event?.action != MotionEvent.ACTION_DOWN) return super.onTouchEvent(event)
val set = ConstraintSet()
set.clone(constraint_layout)
if (!hasAnimated) {
set.setGuidelinePercent(R.id.guideline, 0.2f)
} else {
set.setGuidelinePercent(R.id.guideline, 0.5f)
}
TransitionManager.beginDelayedTransition(constraint_layout)
set.applyTo(constraint_layout)
hasAnimated = !hasAnimated
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment