0

I need an ImageView in which the user of my app loads an image from his gallery or camera. If the image is landscape, the ImageView width should be equal to screen width. If the image is portrait, the ImageView should take up as much screen space as there is available (I have a view above and a view below the ImageView). How can I achieve this?

Below is the desired result:

enter image description here

Revolutionair
  • 760
  • 6
  • 19

1 Answers1

0

First you have to obtain the photo orientation, this can be achieved by reading its EXIF data. The answers to this question can help you to read the EXIF data. Then you have to change the width and height of your ImageView. If the image is portrait then you can use "match_parent" to both height and width. If the image is in landscape then put the height with "wrap_content" and the width in "match_parent". You need to do this by code.

Community
  • 1
  • 1
josemgu91
  • 719
  • 4
  • 8