2016-09-16 68 views
0

我需要将图像添加到我的相对布局中。我发现了一张足够大的图片(1129x1489)。然后我通过这些步骤输入图像。关于Android Image Scaling

  1. 右键点击资源,新图像资源
  2. 选择启动图标(因为我希望我的形象有颜色)
  3. 资产类型选择图片
  4. 选择图片路径
  5. 指定名称并完成

的图像将随后在纹理贴图保存像这样

enter image description here

然而,当添加到布局是非常小的,拉伸时(当设置为match_parentfill_parent)变得模糊。

enter image description here

使用的代码:

<ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@mipmap/big" 
    android:layout_centerVertical="true" 
    android:layout_centerHorizontal="true" 
    /> 

然后,我决定只复制和图像粘贴到绘制文件夹,只需更改代码android:src="@drawable/big"。然后,android模拟器正确显示图像。

enter image description here

enter image description here

我的问题是,是什么样的这一点,将图像的正确方法,为什么它看起来像是正确的图像尺寸(xhdpi)没有被从纹理贴图选择文件夹。

回答

0

在res文件夹中,创建五个文件夹:drawable-hdpi,drawable-mdpi,drawable-xhdpi,drawable-xxhdpi,drawable-xxxhdpi。现在,将适当的图像放入每个文件夹和代码中,将其用作“@ drawable/big”,然后它会正确显示。

+0

是的,但为什么这不与** mipmap **?所有的尺寸已经在那里。如我的照片所示。 – Supercan

+0

Mipmaps仅适用于应用启动图标等。这里解释这里:http://stackoverflow.com/a/24066445/3674262对于在应用程序内使用的图像,可绘制的文件夹是适当的。 –