Android wrap_content不起作用 - 它太大了

时间:2014-12-28 11:54:16

标签: android drawable

我经常与wrap_content合作。它运作正常。

但是最近出了点问题 - 如果我没有给出图像的大小,它看起来比实际大得多。

也许是因为我必须使用Android Studio。 我不知道。

修改

image.png大小为160px x 160px

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

这就是一切看起来都很好。

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

但现在这张照片太大了。

我知道正确的方法是在wrap_content中使用,但因为这个问题我不能。

1 个答案:

答案 0 :(得分:4)

此处已回答类似问题:why is wrap content bigger than real pixel size?

我正在贴出答案以节省时间:

提供了支持多屏幕的非常好的解释

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

缩放后需要将图像放在各个文件夹中。

e.g。如果您想要100 * 100图像,请放置

对于低密度设备,

75 * 75 in drawable-ldpi

对于中等密度设备,

100 * 100 in drawable-mdpi

用于高密度设备的150 * 150 drawable-hdpi

对于超高密度设备,

200 * 200 in drawable-xhdpi