0
我需要知道是否需要設置兩個位圖來顯示兩個ImageView中的圖像。我正在上傳圖庫中的圖片。我們是否需要兩個不同的ImageViews的位圖
代碼: -
public void decodeFile(String filePath) {
// Decode image size
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeFile(filePath, o);
// The new size we want to scale to
final int REQUIRED_SIZE = 1024;
// Find the correct scale value. It should be the power of 2.
int width_tmp = o.outWidth, height_tmp = o.outHeight;
int scale = 1;
while (true) {
if (width_tmp < REQUIRED_SIZE && height_tmp < REQUIRED_SIZE)
break;
width_tmp /= 2;
height_tmp /= 2;
scale *= 2;
}
// Decode with inSampleSize
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize = scale;
bitmap = BitmapFactory.decodeFile(filePath, o2);
//first image i have uploaded by using first button
imgView1.setImageBitmap(bitmap);
imgView2.setImageBitmap(bitmap);
}
是什麼問題?你問是否可以將一個圖像資源分配給多個ImageView? –
@fremmedehenvendelser不,我將不同的圖像資源分配給2個不同的圖像視圖。他們將使用2個不同的按鈕上傳。 – user3492898
您正在爲兩個不同的imageView設置相同的位圖。 – Lunchbox