Created
December 6, 2017 14:08
-
-
Save Stickerbox/dc5c7632bd54d5b394e4f5145a1c4238 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
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