View Source Bitmapdrawable.java. Bitmapdrawable has several methods of construction.
New bitmapdrawable (Bitmap Bitmap) is an early construction method that has been obsolete in Android 4.0 and some of the code is as follows:
This (new Bitmapstate (bitmap), null);
While Google advocates the use of new bitmapdrawable (Bitmap bitmap,resources res), some of the code is as follows:
This (new Bitmapstate (bitmap), res);
It can be seen that the above two methods call a private method: bitmapdrawable (bitmapstate State, resources Res), which is different from the former . A null value, which passed in a non- NULL value. Some of the code in the bitmapdrawable (bitmapstate State, Resources Res) method is as follows:
if (res! = null) {
Mtargetdensity = Res.getdisplaymetrics (). densitydpi;// bitmapdrawable (bitmap,resources) go here
} else {
mtargetdensity = state.mtargetdensity; bitmapdrawable (Bitmap) go here
}
It appears that the current bitmapdrawable is preserving a target density, which, if passed into the resources object, determines a correct density based on the resources (S4 480). Otherwise, the target density of the bitmapstate will be used, and its target density will have a default value:
int mtargetdensity = Displaymetrics.density_default;
Again view Displaymetrics.java Source code, has the following definition:
Public static final int density_default = density_medium;// This value is -
As always stated, in S4 ,new Bitmapdrawable (Bitmap) gets a target density of a whole. The new bitmapdrawable (Bitmap bitmap,resources res) gets a 480 target density. When calculating the width of the Bitmap there are:
Mbitmapwidth = Mbitmap.getscaledwidth (mtargetdensity);
Mbitmapheight = Mbitmap.getscaledheight (mtargetdensity);
In summary, because of the different parameters of the two construction methods, two different width and height values are obtained, so the interface anomaly appears in the drawing. ( specifically why the Width and height of the difference is very large also need to continue to investigate, interested can check again )
Use of Android bitmapdrawable ()