Dev M
Dev M

Reputation: 1709

How can I suppress the missing icon densities lint warning?

I get a lint warning when I include an icon which doesn't have versions for different densities. That is, if I add an icon, myIcon.png, to the drawable-mdpi directory, lint will complain that I don't have versions of myIcon.png in the other drawable directories (drawable-hdpi, -xhdpi, -xxhdpi).

I would like to suppress this warning, either for all icons, or specifically for myIcon.png.

What is the syntax I would need to add to my lint-config.xml to achieve these suppressions?

example lint-config.xml:

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

usage of lint-config.xml in build.gradle (in my Android mobile):

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

Upvotes: 3

Views: 4300

Answers (2)

NPike
NPike

Reputation: 13254

Create a lint.xml with the following contents:

<!-- 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>

Upvotes: 5

android developer
android developer

Reputation: 116322

see this link for graphical designers :

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

in short , they suggest creating multiple images , one for each of the densities , so that it would look perfect (without pixelation or blurryness) on each of the possible densities.

the sizes should be as followed :

  • ldpi - 75% of the original image size
  • mdpi - 100% of the original image size
  • hdpi - 150% of the original image size
  • xhdpi - 200% of the original image size

Upvotes: 4

Related Questions