I have an ImageView (square), I need to enter a photo in such a way that if the photo was taken in a vertical orientation, then the fields remained left and right (Fig. 1), and if in a horizontal orientation, then below and above (Fig. .2). How can I do that? Perhaps there is some special scaleType for this?

Picture 1:

enter image description here

Figure 2:

enter image description here

    1 answer 1

    According to official documentation , for your purposes it is necessary to use

    android:scaleType="fitCenter" //В xml 
    • Works great with photos that were taken in a horizontal orientation, but photos that were made in a vertical orientation are displayed in the same way as those that are in horizontal (only with the wrong rotation), why is this happening? Do they need to force a rotation? - Lucky_girl
    • one
      @Lucky_girl is sometimes found that the wrong orientation. Look, for example, at stackoverflow.com/questions/14066038/… - VAndrJ