ImageView property has two display images, respectively, what role is it?
If both attributes exist, the user will see the background of the src attribute set in. But at the same background background set there, only to be blocked by the src attribute in the back. Src tantamount foreground, background tantamount background.
How to use java code to dynamically change the value of these two properties?
imageView.setImageDrawable (this.getResources () getDrawable ((R.drawable.ic_launcher)).);
ImageView in the XML attributes src and background difference:
background will be based on ImageView components of a given length and width stretch, and it is stored in src original size is not stretched. src is the image content (foreground), bg is the background, it can be used simultaneously.
Also: scaleType only src act; bg transparency can be set, for example, can be used in the ImageView android: scaleType control picture zoom mode, the sample code is as follows:
android: src = "@ drawable / logo"
android: scaleType = "centerInside"
android: layout_width = "60dip"
android: layout_height = "60dip"
android: layout_centerVertical = "true" />
Description: centerInside represents scaled image so that image length (width) of less than equal to the corresponding dimension view.
Note: The picture for control of resources and not the background.
layout should be set: android: src = "@ drawable / logo"
Instead android: background = "@ drawable / logo"
Code settings should be: imgView.setImageResource (R.drawable *.);
Instead imgView.setBackgroundResource (R.drawable *.);