when setting properties with Iamgeview Android:scaletype, fill the screen with various problems
/** * Scale the picture proportionally Setadjustviewbounds setmaxwidth setmaxwidth must be set at the same time * * @param context * @param view * Parent Container * @ param image * Picture control * @param source * Picture resource */public static void Setimageviewmathparent (Activity conte XT, LinearLayout view,imageview image, int source) {Bitmap Bitmap = Bitmapfactory.decoderesource (Context.getresources () , source);D isplaymetrics displaymetrics = new Displaymetrics (); Context.getwindowmanager (). Getdefaultdisplay (). Getmetrics (displaymetrics); float Scalew = (float) displaymetrics.widthpixels/(float) bitmap.getwidth (); Image.setscaletype (Scaletype.matrix); Matrix matrix = new Matrix (); Image.setadjustviewbounds (true); if (Displaymetrics.widthpixels < Bitmap.getwidth ()) { Matrix.postscale (Scalew, Scalew);} else {Matrix.postscale (1/scalew, 1/scalew);} Image.setmaxwidth (displaymetrics.widthpixels); float ss = displaymetrics.heightpixels > Bitmap.getheight ()? DisplayMetrics.heightPixels:bitmap.getHeight (); image.setmaxwidth ((int) SS);View.addview (image); if (bitmap! = null && bitmap.isrecycled ()) {bitmap.recycle ();}}