ImageView - 前景与背景可绘制
在查看应用程序的代码时,我发现它使用带有空前景图像的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
背景图像可以设置在任何视图对象上,并拉伸到视图的大小。图像资源仅适用于 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.
是的,它是安全的。所有小部件都是按照您可以根据您的要求使用的方式设计的。我认为这段代码中没有任何不安全的情况。 :)
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. :)