2016-06-23 10 views
0

Ich habe ein Canvas, auf dem ich Kreise mit drawCircle() zeichne, was ich brauche ist die Erhöhung des Radius dieser Kreise zu animieren. Soweit ich das verstanden habe, ist es möglich, dies mit VectorDrawable und AnimatedVectorDrawable zu tun. Kann mir jemand ein Beispiel geben, wie es geht? oder gibt es andere Möglichkeiten, wie es besser ist?Animation in Android

+2

Sie sollten einen Blick auf 1.) https://developer.android.com/guide/topics/graphics/drawable-animation.html haben und 2.) https://github.com/codepath/android_guides/wiki/Animationen –

Antwort

0

Ich habe mich entschieden, mit Matrix Kreise im Canvas zu animieren.

private int x; 
private int y; 
private Canvas tempCanvas; 
private Matrix matrix = new Matrix(); 
private Path path = new Path(); 

animateCircle(){ 
Paint myPaint = new Paint(); 
myPaint.setAntiAlias(true); 
myPaint.setColor(Color.RED); 
path.addCircle(x, y, 10, Path.Direction.CW); 
//increasing radius of the certain circle 
matrix.setScale(1.1f, 1.1f, x-5, y-5); 
path.transform(matrix); 
tempCanvas.drawPath(path, myPaint4); 
}