How to draw an animation canvas using the code in Android?

I have such code;

   AnimationSet s1 = new AnimationSet(true);
        TranslateAnimation tr1 = new TranslateAnimation(0, 0, -100, -200); 
        tr1.setDuration(6500);
        s1.addAnimation(tr1);
 Paint paint = new Paint();
    Bitmap b = Bitmap.createBitmap(90, 90, Bitmap.Config.ARGB_8888);
    Canvas c1 = new Canvas(b);
    c1.drawCircle(50, 100, 20, paint);

AnimationSet s2 = new AnimationSet(true);
        TranslateAnimation tr2 = new TranslateAnimation(0, 0, -140, -260); 
        tr2.setDuration(6500);
        s1.addAnimation(tr2);
    Canvas c2 = new Canvas(b);
    c2.drawCircle(150, 140, 20, paint);

How to start animation S1 on canvas C1 and animation S2 on canvas C2? If I subclass the view class, I can call the startanimation method on the view class, but how can I use the view class to bind the above animation to the above animation? The sample code is very useful. I can't find a clean Android API that allows me to specify the target of animation. There should be an API that specifies any target graphic object given a series of animation - in my case, canvas object – (not just built-in graphic objects, such as buttons), on which the animation sequence will run

resolvent:

You can add canvas as an image of some components, such as ImageView, and then animate the view

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>