我想借此與Android相機這樣的照片:拍攝照片,並顯示在ImageView的
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
this.startActivityForResult(intent, Globals.REQUEST_CODE_CAMERA)
並將其存儲在一個ImageView的:
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == Globals.REQUEST_CODE_CAMERA) {
if(resultCode == RESULT_OK) {
Bundle bundle = data.getExtras();
Bitmap bitmap = (Bitmap) bundle.get("data");
this.imageViewPhoto.setImageBitmap(bitmap);
}
}
}
我ImageView的配置像這樣:
<ImageView
android:id="@+id/nfcresult_imageview_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:adjustViewBounds="true"
android:clickable="true"
android:contentDescription="@string/imageview_photo_description" />
的所有作品,但是對ImageView的顯示的照片比小得多0相機拍攝的照片。我想要做的是在我的 ImageView中預覽一個小圖片,並在ImageView中添加一個OnClickListener來打開一個對話框 ,它顯示原始大小和分辨率的原始照片。它不能 難以做到這一點,但我實際上不能找出如何。
創建對話框並顯示照片我這樣做:
ImageView clone = new ImageView(this);
clone.setImageBitmap(((BitmapDrawable)this.imageViewPhoto.getDrawable()).getBitmap());
DialogManager.showImageDialog(this, this.getResources().getString(R.string.title_photo), clone);
的showImageDialog:
public static void showImageDialog(Context context, String title, ImageView imageView) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title);
builder.setCancelable(false);
builder.setView(imageView);
builder.setPositiveButton(context.getResources().getString(R.string.button_back), new DialogInterface.OnClickListener() {
/**
*
*/
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
對話框現在顯示存儲在ImageView的照片大小的照片 但我想顯示原始大小和原始分辨率的原始照片 ,但正如我已經說過的,ImageView應顯示原始 照片的較小版本。
我該如何做到這一點?
http://androidexample.com/Camera_Photo_Capture_And_Show_Captured_Photo_On_Activity_/index.php?view=article_discription&aid=77&aaid=101 – 2014-11-04 07:41:02
http://stackoverflow.com/questions/5991319/capture-image -from-camera-and-in-activity – 2014-11-04 07:43:01
Thank you for the links ... but much deprecated stuff there ... – Mulgard 2014-11-04 08:17:39