1
TranslateAnimation animation = new TranslateAnimation(0.0f, 1552.0f,0.0f, 0.0f);        //  new TranslateAnimation(xFrom,xTo, yFrom,yTo)
    `animation.setDuration(2000);`  // animation duration 
    animation.setRepeatCount(100);  // animation repeat count
    animation.setRepeatMode(1);   // repeat animation (left to right, right to left )
    animation.setFillAfter(true);      
    pro.startAnimation(animation);
    progress.startAnimation(animation);  // start animation 

我想要随机左动画

4

1 回答 1

0

如果您只想制作一个随机的 xDelta,那么您可以使用如下代码:

Random randomGenerator = new Random(system.currentTimeMillis());
TranslateAnimation animation = new TranslateAnimation(0.0f, randomGenerator.nextFloat() * 1552.0f,0.0f, 0.0f);

它将产生 0 到 1552 之间的随机 xDelta

于 2014-07-22T12:31:07.093 回答