【问题标题】:How can I suppress the missing icon densities lint warning?如何抑制丢失的图标密度 lint 警告?
【发布时间】:2012-06-09 19:55:39
【问题描述】:

当我包含一个没有不同密度版本的图标时,我会收到一个 lint 警告。也就是说,如果我在 drawable-mdpi 目录中添加一个图标 myIcon.png,lint 会抱怨我在其他可绘制目录(drawable-hdpi、-xhdpi、-xxhdpi)中没有myIcon.png 的版本.

我想禁止显示此警告,无论是针对所有图标,还是专门针对 myIcon.png

我需要在lint-config.xml 中添加什么语法来实现这些抑制?

例如lint-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<lint>
  <issue id="MissingTranslation" severity="ignore" />
</lint>

build.gradle 中使用lint-config.xml(在我的Android 手机中):

android {
    lintOptions {
        lintConfig file("lint-config.xml")
    }
}

【问题讨论】:

  • 只需为包括中等密度在内的各种密度创建这些图像...您应该将之前的一些问题标记为已回答,因为他们的建议是准确的。
  • 为什么投反对票?我认为这是一个非常有效的问题。

标签: android lint


【解决方案1】:

创建一个包含以下内容的 lint.xml:

<!-- Ignore the IconDensities issue in the given files -->
<issue id="IconDensities">
    <ignore path="**/res/drawable-mdpi/myIcon.png"/>
    <ignore path="**/res/drawable-hdpi/myIcon.png"/>
    <ignore path="**/res/drawable-xhdpi/myIcon.png"/>
    <ignore path="**/res/drawable-xxhdpi/myIcon.png"/>
</issue>

【讨论】:

    【解决方案2】:

    请参阅此链接了解图形设计师:

    http://developer.android.com/design/style/devices-displays.html

    简而言之,他们建议为每种密度创建多张图像,以便在每种可能的密度上看起来都很完美(没有像素化或模糊)。

    尺寸应如下:

    • ldpi - 原始图像大小的 75%
    • mdpi - 原始图像大小的 100%
    • hdpi - 原始图像大小的 150%
    • xhdpi - 原始图像大小的 200%

    【讨论】:

    • 一点信息:如果可能,最好在设计图形时考虑 xhdpi - 然后按比例缩小所有其他图形。应该不言而喻,但我想我会注意到这一点。
    • 不完全是(取决于他会做什么):如果他创建 xhdpi 并简单地调整图像大小,它对 android 没有多大帮助,因为它可以做同样的事情。但是,如果他使用矢量图形,应该会好很多,从哪里开始都无所谓。还有,
    猜你喜欢
    • 2021-02-12
    • 2016-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-25
    • 2011-03-18
    相关资源
    最近更新 更多