2016-12-11 16 views
1

내 응용 프로그램에 애니메이션을 보여주고 싶습니다.이 애니메이션을 3000m/s마다 보여주고 싶습니다.
아래 코드를 작성했지만이 코드에는 한 번만 표시됩니다.안드로이드에서 매번 코드를 실행하는 방법

new Handler().postDelayed(new Runnable() { 
    @Override 
    public void run() { 
     YoYo.with(Techniques.Bounce) 
       .duration(1500) 
       .playOn(arrowHelpImage); 
    } 
}, 3000); 

어떻게하면 코드를 편집하고 각 3000m/s를 표시 할 수 있습니까?

답변

0

U는 이와 비슷한 것을 사용할 수 있습니다. 아래에서 사용 된 애니메이션을 변경하십시오. 이 애니메이션은 무한하게 돌아갑니다. Listner에 애니메이션을 제공하십시오. 애니메이션 지속 시간을 3000ms로 변경하고 handler.it에서 사용할 수 있습니다. 작업 할 수 있습니다.

YoYo.with(Techniques.Bounce) 
    .duration(1200) 
    .interpolate(new AccelerateDecelerateInterpolator()) 
    .withListener(new Animator.AnimatorListener() { 

     @Override 
     public void onAnimationStart(Animator animation) {} 

     @Override 
     public void onAnimationEnd(Animator animation) { 
      YoYo.with(Techniques.Bounce) 
      .duration(1200) 
      .interpolate(new AccelerateDecelerateInterpolator()) 
      .withListener(this).playOn(arrowHelpImage); 
     } 

     @Override 
     public void onAnimationCancel(Animator animation) {} 

     @Override 
     public void onAnimationRepeat(Animator animation) {} 
    }).playOn(arrowHelpImage); 
+0

덕분에 내 친구에서 OnCreate 코드 아래

private Handler handler; private Runnable runnable; 

<3 –

0

클래스에 아래 코드를 입력하십시오. 당신이

handler = new Handler(); 
     runnable = new Runnable() { 
      @Override 
      public void run() { 


YoYo.with(Techniques.Bounce) 
       .duration(1500) 
       .playOn(arrowHelpImage); 
       handler.postDelayed(runnable, Constants.SPLASH_DURATION); 
      } 
     }; 
     handler.postDelayed(runnable, Constants.SPLASH_DURATION); 


@Override 
protected void onDestroy() { 
    super.onDestroy(); 
    //Close the handler and the process of splash screen. 
    if (handler != null && runnable != null) { 
     handler.removeCallbacks(runnable); 
    } 
}