How can I call the onDraw () method for Android view 30 times per second

For Android, I have a custom view, which I fill with primitive shapes in the onDraw () method.

Based on the processing background, I expected the draw method to be called automatically 30 times per second, but it’s clear that this is not how androids work.

So, how do I access this method 30 times per second?

+4
source share
1 answer

Use animation and call startAnimation () on it from your view.

I do not know that you can set a target frame rate - rather, you expect to set start and end points in time and can interpolate at any point in time between them.

If you don't like this approach, you might think of another thread that periodically calls view.postInvalidate() to request a reprogramming of the View .

+6
source

Source: https://habr.com/ru/post/1299846/


All Articles