How to draw animation on canvas? (Android)

I am trying to show animation on a canvas when the user touches the screen. I know the basics and how to draw a bitmap on canvas, but I could not find anything good in drawing or showing animations on canvas.i use frame-by-frame animation and it will appear in the same place as the user, and therefore I I can not use ImageView.

+4
source share
1 answer

Not sure if there is a built-in way to do this. But it's pretty simple to load bitmaps into an array.

Then call invalidate (), your onDraw () method itself must invalidate () and in the next run calculate what frame to display (by calculating the display time of the last frame). Each time you play a frame, you increase the frame counter and reset the time counter.

You can use a variable delay, and it's pretty easy to implement.

+6
source

All Articles