Question

Tout d'abord du tout, peut-être "paysage" n'est peut-être pas le meilleur mot à décrire, mais je ne peux pas penser un autre dans le moment.

J'utilise le code suivant pour afficher une image dans une vue d'écran, mais mon image prise avec l'appareil dans "Portrait" (tête haute) montre Sidelong.

Mon code:

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

et oui, "contenu: // support / externe / images / multimédia / 7" est un chemin valide.

Des idées?

Était-ce utile?

La solution

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);

Autres conseils

android:id="@+id/iv_photo"

android:layout_width="320dip"   

android:layout_height="wrap_content"/>

Use this it may works

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top