我使用以下片段(来自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);
}
嘿,看到我更新的答案。 –