Android Hierarchy and Structure
I开发者_高级运维 want to create an app that has multiple animations on the screen AT THE SAME TIME, to be specific:
- RPM Gauge animation
- MPH Gauge animation
- Direction of wheel animation
I believe to make all these 2D graphic fastest i should use SurfaceView with threading. My question is how i should structure this app.
A) Should each animation be its own class? If so how do I bring all the onDraw() functions together in a single view?
B) The animations are independent of each other so do i still require synchronized threading? If not can i just use one thread class for all animations or should I create 3 separate ones?
A) The two gauges and the wheel are independent of each other, so I would create three separate Views of each. A SurfaceView is I believe a good option for each. Also, the drawing will be completely different in each, so yes, I would create different classes. Perhaps, depending on how the two gauges will be drawn, you might want to use two instances of the same Gauge class.
B) Since the SurfaceView takes care of the threading for the drawing, you do not need to create any new thread for them.
精彩评论