Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. @Override
  2. public boolean onTouch(View view, MotionEvent event) {
  3.  
  4. //int action = event.getAction();
  5. switch (event.getAction()) {
  6. case MotionEvent.ACTION_DOWN:
  7. carcolor.setBackgroundColor(this.getResources().getColor(R.color.colorPrimary));
  8.  
  9. car.startAnimation(pressdown);
  10. pressdown.setAnimationListener(new Animation.AnimationListener() {
  11.  
  12. @Override
  13. public void onAnimationStart(Animation animation) {
  14. carback.setScaleX((float) 0.9);
  15. carback.setScaleY((float) 0.9);
  16. }
  17.  
  18. @Override
  19. public void onAnimationEnd(Animation animation) {
  20. carback.setVisibility(View.VISIBLE);
  21. car.setVisibility(View.INVISIBLE);
  22. }
  23.  
  24. @Override
  25. public void onAnimationRepeat(Animation animation) {
  26.  
  27. }
  28. });
  29.  
  30. break;
  31.  
  32. case MotionEvent.ACTION_MOVE:
  33. break;
  34.  
  35. case MotionEvent.ACTION_UP:
  36. car.startAnimation(release);
  37.  
  38. carcolor.setBackgroundColor(this.getResources().getColor(R.color.unpressed));
  39.  
  40. release.setAnimationListener(new Animation.AnimationListener() {
  41.  
  42. @Override
  43. public void onAnimationStart(Animation animation) {
  44. carback.setVisibility(View.INVISIBLE);
  45. }
  46.  
  47. @Override
  48. public void onAnimationEnd(Animation animation) {
  49. car.setVisibility(View.VISIBLE);
  50. }
  51.  
  52. @Override
  53. public void onAnimationRepeat(Animation animation) {
  54.  
  55. }
  56. });
  57.  
  58.  
  59. break;
  60.  
  61. case MotionEvent.ACTION_CANCEL:
  62. break;
  63. }
  64. return true;
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement