开发者

How should I call the onDraw() method of an Android view 30 times per second

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

Coming from a Processing background, I expected the draw method to be called automatically 30 times per second, but its clear that that's not how android views work.

So how s开发者_开发问答hould I go about calling this method 30 times per second?


Use an Animation, and call startAnimation() on it from your View.

I don't know that you can set a target framerate -- rather, you're expected to set start and end points in time, and be able to interpolate for any point in time between the two.

If you don't like this approach, you might consider having another thread which periodically calls view.postInvalidate() to request that your View be redrawn.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜