Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MaxWidth and MaxHeight is not working in ImageView [duplicate]

Tags:

android

I am using an ImageView in Android where I initially set the layout_height and layout_width to wrap_content as well as set the maxHeight and maxWidth attributes.

This is how it looks like in my layout:

<ImageView
    android:id="@+id/profileImageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:maxWidth="226dp"
    android:maxHeight="174dp"
    android:background="@drawable/photo" />

But when I pick a picture from the gallery then it covers my entire screen, ignoring the maxWidth and maxHeight. How can I resolve this issue ?

like image 912
N Sharma Avatar asked Dec 08 '14 19:12

N Sharma


1 Answers

Add android:adjustViewBounds="true"

like image 81
tachyonflux Avatar answered Oct 17 '22 11:10

tachyonflux