我使用以下片段(來自SO帖子here),將使用相機拍攝的照片作爲縮略圖顯示在imagevew中。但圖片的縮略圖不顯示並保持空白。可能是什麼原因?設置使用相機拍攝的照片,作爲圖像視圖中的縮略圖
Bundle extras = data.getExtras();
if(extras.get("data") != null){
Bitmap imageBitmap = (Bitmap) extras.get("data");
// Get the dimensions of the View
int targetW = imgViewPreview.getWidth();
int targetH = imgViewPreview.getHeight();
// Get the dimensions of the bitmap
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
Bitmap bitmap = Bitmap.createScaledBitmap(picture, targetW, targetH, true);
imgViewPreview.setVisibility(View.VISIBLE);
imgViewPreview.setImageBitmap(imageBitmap);
}
嘿,看到我更新的答案。 –