下面的代碼是用來調整所選圖像
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