Android onDraw() 方法并添加图像

发布于 2024-11-14 16:32:08 字数 112 浏览 8 评论 0 原文

我有一个视图,我出于动画目的重写了 onDraw() 函数。但是,有些图像我希望在视图中保持静态,我是否也必须在 onDraw() 函数中绘制这些图像,或者我可以通过 XML 或其他内容作为模板应用这些图像吗?

I have a view where i have overriden the onDraw() function for animation purposes. However there are some images i would to like to be static in the view do i have to draw these images in the onDraw() function as well or can i apply these images via XML or something as a template?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

肩上的翅膀 2024-11-21 16:32:08

仅重写您要自己绘制的视图的 onDraw() 方法。否则你必须自己画它们。

Only override the onDraw() method of the views you want to draw by yourself. Otherwise you have to paint them yourself.

暖心男生 2024-11-21 16:32:08

您可以尝试框架布局,它有一个用于静态图像的子视图和一个用于动画图像的子视图。否则,我想你每次都得重画。
另外不要忘记其他动画方法

You can try a frame layout, which would have a child view for your static image and a child view for your animated images. Otherwise, I think you would have to redraw it each time.
Also don't forget about other animation methods

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文