Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public boolean onTouch(View view, MotionEvent event) {
- //int action = event.getAction();
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- carcolor.setBackgroundColor(this.getResources().getColor(R.color.colorPrimary));
- car.startAnimation(pressdown);
- pressdown.setAnimationListener(new Animation.AnimationListener() {
- @Override
- public void onAnimationStart(Animation animation) {
- carback.setScaleX((float) 0.9);
- carback.setScaleY((float) 0.9);
- }
- @Override
- public void onAnimationEnd(Animation animation) {
- carback.setVisibility(View.VISIBLE);
- car.setVisibility(View.INVISIBLE);
- }
- @Override
- public void onAnimationRepeat(Animation animation) {
- }
- });
- break;
- case MotionEvent.ACTION_MOVE:
- break;
- case MotionEvent.ACTION_UP:
- car.startAnimation(release);
- carcolor.setBackgroundColor(this.getResources().getColor(R.color.unpressed));
- release.setAnimationListener(new Animation.AnimationListener() {
- @Override
- public void onAnimationStart(Animation animation) {
- carback.setVisibility(View.INVISIBLE);
- }
- @Override
- public void onAnimationEnd(Animation animation) {
- car.setVisibility(View.VISIBLE);
- }
- @Override
- public void onAnimationRepeat(Animation animation) {
- }
- });
- break;
- case MotionEvent.ACTION_CANCEL:
- break;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement