How To Generate Looping Animation With Viewpropertyanimator?
I want to build an animation of TextViews, which repeats itself just after completion. For each View I want to animate, I use the following piece of code final float oldX = v.getX
Solution 1:
Well, I am going to answer myself again.
TranslateAnimation class has methods about repeating the animation, so I used it instead of ViewPropertyAnimator.
The following code seems to work:
longduration=1000* ((long)totalWidth / newsScrollSpeed);
System.out.println("totalWidth="+totalWidth);
TranslateAnimationanim=newTranslateAnimation(0,-totalWidth,0,0);
anim.setInterpolator(linearInterpolator);
anim.setDuration(duration);
anim.setRepeatCount(TranslateAnimation.INFINITE);
anim.setRepeatMode(TranslateAnimation.RESTART);
for(i=0;i<this.getChildCount();i++)
{
Viewv=this.getChildAt(i);
if(v.getId() == R.id.yuruyen_yazi)
{
continue;
}
v.startAnimation(anim);
}
Solution 2:
Not elegant way, but it works:
Runnablerunnable=newRunnable() {
@Overridepublicvoidrun() {
// update newX
v.animate().setDuration(animDuration).setInterpolator(newsInterpolator).x(newX).withEndAction(this).start();
}
};
v.animate().setDuration(animDuration).setInterpolator(newsInterpolator).x(newX).withEndAction(runnable).start();
Post a Comment for "How To Generate Looping Animation With Viewpropertyanimator?"