Android 的层次结构
我想创建一个在屏幕上同时具有多个动画的应用程序,具体来说:
- RPM 仪表动画
- MPH 仪表动画
- 车轮动画的方向
我相信要使所有这些 2D 图形速度最快,我应该使用带有线程的 SurfaceView。我的问题是我应该如何构建这个应用程序。
A) 每个动画都应该是它自己的类吗?如果是这样,如何将所有 onDraw() 函数集中在一个视图中?
B)动画是相互独立的,所以我还需要同步线程吗?如果不是,我可以只对所有动画使用一个线程类,还是应该创建 3 个单独的线程类?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
A)两个仪表和车轮彼此独立,因此我将为每个仪表创建三个单独的视图。我相信 SurfaceView 对于每个人来说都是一个不错的选择。另外,每个类的绘图都完全不同,所以是的,我会创建不同的类。也许,根据两个仪表的绘制方式,您可能想要使用同一 Gauge 类的两个实例。
B) 由于 SurfaceView 负责绘图的线程,因此您不需要为它们创建任何新线程。
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.