I have an ImageView
that has:
android:layout_height="100dp"
android:layout_width="wrap_content"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
What I see is that if I set an image that has as dimensions (based on the info of my pc) 1280px854
If I open it in my pc the image looks huge.
The same image is small in my ImageView
although I have set wrap_content
.
I am not sure I get how this works. E.g. 1280/4 = 320dpi (xxxhdpi) but for with wrap_content
the image view does not have as width 320dpi
To clarify: I am trying to understand why it works like that and does not make it bigger with wrap_content
.
First, let's talk about the ratio of your image. It's 1280px wide and 854px tall, hence, its proportion is 1280/854 ≈ 3/2.
Second, you've set the height of your ImageView
to 100dp
. If the width is not specified, then android will try its best to perceive the ratio (3/2) and will calculate the width:
ratio = width/height
3/2 = width/100
width = 150dp
Notice it gave us dp
, if we were to plug px
instead(for the height) it will give us px back.
Third, now that we have the size of the image (150dp x 100dp) and width='wrap_content'
the width of the imageView will correspond to the 150dp