下面的代码是用来调整所选图像
Bitmap bitmap = BitmapFactory.decodeStream(newurl.openConnection() .getInputStream());
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int newWidth = 100;
int newHeight = 100;
// calculate the scale - in this case = 0.4f
float scaleWidth = ((float) newWidth)/width;
float scaleHeight = ((float) newHeight)/height;
// createa matrix for the manipulation
Matrix matrix = new Matrix();
// resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0,
width, height, matrix, true);
((ImageView) findViewById(R.id.ImageviewTest)).setImageBitmap(resizedBitmap);
这是更好地利用图像代码的大小调整前将图像的ImageView – Pinki
你的意思,我不能让你。请多关注一下这个评论。 – Rocker
调整所选图像的大小。当你调整图像大小,以减少大小,以避免内存不足异常 – Pinki