Я бы добавил новое значение с плавающей точкой в диапазоне от 0 до 1, которое сохраняет текущий процент анимации, и использовал бы его, чтобы установить текущую альфа
public class MyView extends View {
private Path paths[];
private float mAnimPercentage = 0.0f;
private static final int clip(int value){ //forces the value to be between 0 and 255
return Math.max(0, Math.min(255, value));
}
protected void onDraw( Canvas canvas ) {
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth( 8 );
paint.setColor(Color.BLUE);
Path path = new Path();
path.moveTo(75, 11);
path.quadTo(62, 87, 10, 144);
//edited here
paint.setAlpha(clip(mAnimPercentage*255*2));
canvas.drawPath( path, paint );
paths[0] = path;
path.reset();
path.moveTo(50, 100);
path.lineTo(150, 200);
//edited here
paint.setAlpha(clip(-127 + mAnimPercentage*255*2)); //the biggest is the negative value, the latter this path will show, the biggest is the number multiplied by mAnimPercentage, the fastest this path will get completely opaque
canvas.drawPath( path, paint );
paths[1] = path;
mAnimPercentage+= 0.01; //FIXME this is for TEST only, you should update it with an animator
postInvalidate();
}
}