/*** 设置图片根据屏幕宽度进行等比例缩放* @param imageView*/public static void setImageMatchScreenWidth(ImageView imageView){BitmapDrawable bitmapDrawable = (BitmapDrawable) imageView.getDrawable();if(bitmapDrawable == null)return;Bitmap bitmap = bitmapDrawable.getBitmap();if(bitmap == null)return;int defaultWidth = AppUtil.catchDisplayWidth(imageView.getContext());float scale = (float) defaultWidth / (float) bitmap.getWidth(); int defaultHeight = Math.round(bitmap.getHeight() * scale);LayoutParams params = imageView.getLayoutParams();params.width = defaultWidth;params.height = defaultHeight;imageView.setLayoutParams(params);}
700字范文,内容丰富有趣,生活中的好帮手!