我正在从图库(相册)中选取的imageview上设置图像.如果摄取的图像具有横向,它显示完美,但如果在肖像模式(即图像被点击在纵向模式下),它会显示一个90度旋转图像的图像.现在我试图在设置imageview之前找出方向,但所有图像都给出相同的方向和相同的宽度 - 高度.这是我的代码:
Uri selectedImage = intent.getData();
if (selectedImage != null) {
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), selectedImage);
int str = new ExifInterface(selectedImage.getPath()).getAttributeInt("Orientation", 1000);
Toast.makeText(this, "value:" + str, Toast.LENGTH_LONG).show();
Toast.makeText(this, "width:" + bitmap.getWidth() + "height:" + bitmap.getHeight(), Toast.LENGTH_LONG).show();
Run Code Online (Sandbox Code Playgroud)
