//取得图片的分辨率
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(getResources(), R.drawable.son35,options);
int imgHeight = options.outHeight;
int imgWidth = options.outWidth;
//取得手机系统的屏幕分辨率
WindowManager manager = getWindowManager();
Point point = new Point();
manager.getDefaultDisplay().getSize(point);
manager.getDefaultDisplay().getSize(point);
int screenHeight = point.y;
int screenWidth = point.x;
//计算宽和高的缩放比
int scaleHeight = imgHeight / screenHeight;
int scaleWidth = imgWidth / screenWidth;
int size = scaleHeight>=scaleWidth?scaleHeight:scaleWidth;
options.inSampleSize = size;
//解析图片
options.inJustDecodeBounds = false;
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.son35,options);
iv.setImageBitmap(bitmap);