Guest User

Untitled

a guest
Jul 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. public void myfun1()
  2. {
  3.  
  4. int[] dest = new int[2];
  5.  
  6. linearTop=(ImageView)findViewById(R.id.redDot);
  7. lineardown = (ImageView) findViewById(R.id.circlarea);
  8. linearFingerPlacedown.getLocationOnScreen(dest);
  9.  
  10. final float tempDest = (float) dest[1];
  11.  
  12. TranslateAnimation anim = new TranslateAnimation(0f, 0f, 0,tempDest
  13. );
  14. anim.setInterpolator(new LinearInterpolator());
  15. anim.setRepeatCount(Animation.ABSOLUTE);
  16. anim.setDuration(2000);
  17. linearTop.startAnimation(anim);
  18. final TranslateAnimation Reverse = new TranslateAnimation(0f, 0f,
  19. tempDest , 0);
  20. Reverse.setInterpolator(new LinearInterpolator());
  21. Reverse.setRepeatCount(Animation.ABSOLUTE);
  22. Reverse.setDuration(2000);
  23.  
  24. anim.setAnimationListener(new AnimationListener()
  25. {
  26.  
  27. @Override
  28. public void onAnimationStart(Animation animation)
  29. {
  30.  
  31.  
  32. }
  33.  
  34. @Override
  35. public void onAnimationRepeat(Animation animation)
  36. {
  37.  
  38. }
  39.  
  40. @Override
  41. public void onAnimationEnd(Animation animation)
  42. {
  43.  
  44. settingplace();
  45. linearTop.startAnimation(Reverse);
  46. }
  47. });
  48. }
  49. ==============
  50.  
  51. public void settingplace()
  52. {
  53.  
  54. System.out.println("place1:" + place);
  55. System.out.println("dp:" + dp);
  56.  
  57. System.out.println("count:" + count);
  58. if ( count %2==0 && count < 10)
  59. {
  60. ImageView reddot=(ImageView)findViewById(R.id.redDot);
  61. LinearLayout.LayoutParams lp =(LinearLayout.LayoutParams) reddot.getLayoutParams();
  62. lp.setMargins(0, (int) (place), 0, 0);
  63.  
  64. reddot.setLayoutParams(lp);
  65.  
  66. place = (int) (place + (40 * dp));
  67. }
  68. }
Add Comment
Please, Sign In to add comment