Reputation: 1236
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.
Upvotes: 0
Views: 5714
Reputation: 18489
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. :)
Upvotes: 0
Reputation: 24857
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.
Upvotes: 4