artist
artist

Reputation: 6371

Display horizontal and vertical images in imageview

I am getting pictures from the sdcard in my app. I am using imageview to display image. However since I dont know if the image will be horizontal or vertical, how can I show horizontal or vertical image in imageview appropriately.Thanks

 File img_file = new File(picture_path);
        bm = BitmapFactory.decodeFile(img_file.getAbsolutePath());
        iv2.setImageBitmap(bm);

imageview xml

 <ImageView
    android:id="@+id/iv_image2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="5dp"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    android:scaleType="fitXY"
    android:adjustViewBounds="true"
    />

Upvotes: 1

Views: 3382

Answers (1)

JasonOfEarth
JasonOfEarth

Reputation: 739

This is unfortunately kind of a complicated thing to do. You can read the Xif data and determine its orientation, see How to determine orientation of picture without ExifInterface? and Android get Orientation of a camera Bitmap? And rotate back -90 degrees for ideas. Then you can rotate it manually.

Upvotes: 1

Related Questions