5

まず第一に、「風景」という表現は適切ではないかもしれませんが、現時点では別の言葉を思いつきません。

次のコードを使用して ImageView に画像を表示していますが、デバイスを「縦向き」(頭を上に向けた状態) で撮影した画像が横向きに表示されています。

私のコード:

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"/>

はい、「content://media/external/images/media/7」は有効なパスです。

何か案は?

4

2 に答える 2

3

画像の寸法を確認してください。幅よりも高さが高い場合は、回転できます:
http://android-er.blogspot.com/2010/07/rotate-bitmap-image-using-matrix.html

関連するビットは次のとおりです。

  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);
于 2012-01-26T18:59:20.557 に答える
0

android:id="@+id/iv_photo"

android:layout_width="320dip"   

android:layout_height="wrap_content"/>

これを使用するとうまくいくかもしれません

于 2012-05-02T05:42:46.180 に答える