ImageView - 前景与背景可绘制

发布于 2024-12-18 17:14:32 字数 218 浏览 2 评论 0原文

在查看应用程序的代码时,我发现它使用带有空前景图像的 ImageView 的背景图像设置:

staticon.setImageResource(0);
staticon.setBackgroundResource(R.drawable.switch_to_on);

这种方法的优点和缺点是什么?将其重构为仅使用前景图像是否安全?设置的可绘制对象是帧动画。

In reviewing the code of an App, I see that it uses the background image setting for an ImageView with an empty foreground image:

staticon.setImageResource(0);
staticon.setBackgroundResource(R.drawable.switch_to_on);

What are the pro's and cons of this approach? Will it be safe to refactor this to just use the foreground image? The drawable being set is a Frame Animation.

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

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

发布评论

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

评论(2

末が日狂欢 2024-12-25 17:14:32

背景图像可以设置在任何视图对象上,并拉伸到视图的大小。图像资源仅适用于 ImageView,允许您缩放并对图像进行更多控制。您可以使用比例类型来调整图像的显示方式。

A background image may be set on any view object and is stretched to the size of the view. The image resource is for ImageView only and allows you to scale and have more control over the image. You can use scale type to adjust how the image is displayed.

风苍溪 2024-12-25 17:14:32

是的,它是安全的。所有小部件都是按照您可以根据您的要求使用的方式设计的。我认为这段代码中没有任何不安全的情况。 :)

Yes it is safe.All the widgets are designed in the way you can use according to your requirement.I dont think any unsafe situation in this code. :)

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