当我在图像视图中查看时,图像会更改为横向

时间:2018-02-05 16:05:30

标签: android performance android-layout android-camera android-camera-intent

我需要捕捉图像并在Image View

中显示

这就是我所做的;

btnLaunchCamera.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        activeTakePhoto();
    }
});


private void activeTakePhoto() {
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    File photo = new File(Environment.getExternalStorageDirectory(), FILE_NAME);
    intent.putExtra(MediaStore.EXTRA_OUTPUT,
            Uri.fromFile(photo));
    imageUri = Uri.fromFile(photo);
    startActivityForResult(intent, 119);
}

enter image description here

当我按OK时,它会显示图像视图,这是我在图像视图中显示图片的方法。

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        selectedImage = imageUri;
        Intent intent= new Intent(CameraLauncherActivity.this, MainActivity.class);
        intent.putExtra("imageBitmap", selectedImage);
        startActivity(intent);
}

MainActivity

imageUri=  (Uri) intentData.getExtras().get("imageBitmap");
mImageView.setImageURI(imageUri);

enter image description here

0 个答案:

没有答案