我引用AVLoadingIndicatorView(演示.gif中的第5行第3列)我能够绘制圆圈,但它让我很难给它制作动画。 这是我绘制圆圈的代码:
void draw(){...
float startX=(getWidth()/2)-(total/2) ;
for (int i=1;i<18;i++){
float position=startX+(30*i);// position the circle into middle(w.r.t existing ones)
canvas.scale(1.5f,1.5f);
canvas.drawCircle(position,getHeight()/2,8,paint);
}
这是AVLoadingIndicator的createAnimation方法:
@Override
public List<Animator> createAnimation() {
List<Animator> animators=new ArrayList<>();
long[] delays=new long[]{100,200,300,400,500};
for (int i = 0; i < 5; i++) {
final int index=i;
ValueAnimator scaleAnim=ValueAnimator.ofFloat(1, 0.4f, 1);
scaleAnim.setDuration(1000);
scaleAnim.setRepeatCount(-1);
scaleAnim.setStartDelay(delays[i]);
scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleYFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
scaleAnim.start();
animators.add(scaleAnim);
}
return animators;
}
输出给出了一堆视图,只是坐在那里无所事事...... 我究竟做错了什么?以及如何实现所描述的动画.. ??