offset
offset

Reputation: 1407

Android wrap_content not work - It's too big

I often work with wrap_content. And it works properly.

But recently something went wrong - if I do not give the size of the image, it looks a lot bigger than it really is.

Maybe it's because I had to work with Android Studio. I do not know.

Edit:

image.png size is 160px x 160px

<ImageView
          android:layout_width="160px"
          android:layout_height="160px"
          android:src="@drawable/image" />

That's how everything looks fine.

<ImageView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/image" />

But now that picture looks too big.

I know that the right way is to use in wrap_content, but because this issue I can't.

Upvotes: 6

Views: 6230

Answers (1)

abhi
abhi

Reputation: 1444

Similar question has been answered here: why is wrap content bigger than real pixel size?

I am pasting the answer to save time:

A very nice explaintaion for supporting the multiple screens is given at

http://developer.android.com/guide/practices/screens_support.html.

you need to put images in respective folders after scaling.

e.g. if you want 100*100 image then place

75*75 in drawable-ldpi for Low density devices

100*100 in drawable-mdpi for Medium density devices

150*150 in drawable-hdpi for High density devices

200*200 in drawable-xhdpi for Extra High density devices

Upvotes: 5

Related Questions