Android - Galleryからの画像ビューを「ランドスケープ」
質問
最初のまず、「風景」は説明するのは良い言葉ではありませんが、現時点では別のものを考えることはできません。
次のコードを使用して画像ビューに画像を表示していますが、デバイスで撮影された画像(ヘッドアップ)に撮影されているイメージがサイレージを表示しています。
マイコード:
mImageView = (ImageView) findViewById(R.id.iv_photo);
Uri u = Uri.parse("content://media/external/images/media/7");
mImageView.setImageURI(u);
.
XML:
<ImageView
android:id="@+id/iv_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
.
とyes、 "content:// media / external / image / media / 7"は有効なパスです。
任意のアイデア?
解決
Just check the image's dimensions, if it's taller than it is wider, then you can rotate it:
http://android-er.blogspot.com/2010/07/rotate-bitmap-image-using-matrix.html
The relevant bits are:
bitmap = BitmapFactory.decodeFile(imageInSD);
bmpWidth = bitmap.getWidth();
bmpHeight = bitmap.getHeight();
Matrix matrix = new Matrix();
matrix.postScale(curScale, curScale);
matrix.postRotate(curRotate);
Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bmpWidth, bmpHeight, matrix, true);
myImageView.setImageBitmap(resizedBitmap);
他のヒント
android:id="@+id/iv_photo"
android:layout_width="320dip"
android:layout_height="wrap_content"/>
Use this it may works
所属していません StackOverflow