There are two possible answers to your question. The first, and to which anyone would respond, is what the @Ramaral quoted.
In quote to his comment, I will summarize as an answer. You will have to create two images, with the same name, but with resolutions appropriate for lang
and port
. To do this, your setting in /res
should look like this:
Drawable-land
imagem.png
Drawable-port
imagem.png
There's a catch-all when you set up such a setup: you'd have to create two images for each resolution type, which is a bit damaging.
The second answer is the simplest and most compact. You create only one image and use it at any resolution, because the image is self resizable.
The answer comes from a question I asked myself: When and why should we use SVG?
If we use SVG
, we only create one file and use it in different resolutions, without losing it. Here's the answer:
I've learned to vector "stuff" in Corel Draw, and this business of images does not lose quality is the maximum. (blablabla)
From Lollipop (API 21), Android included the class VectorDrawable
, to define drawables based on vector graphics. Android Studio 1.4 adds the Vector Asset Studio to make them easier to work with, including an SVG import feature and a new Gradle plugin that generates PNG versions of VectorDrawable
at compile time for API 20 and earlier versions. There are also third-party tools for converting SVGs to VectorDrawables
. Keep in mind that although the drawables vector can be defined in XML, the file format is not SVG and not all SVG files can be converted successfully.
Is it recommended to start a transition from PNG to SVG in the application?
According to the documentation , the use of vector characters instead of < in> bitmaps reduces the size of the APK because the same file can be resized to different screen densities without loss of image quality.
We have that every library added to a project brings many possibilities and features, but libraries usually contain a large amount of code files and resources, among them, unnecessary resources depending on each type of situation. This creates a kind of residue: applications have a lot of things that are never actually used. More than that, the size of packages are growing at a rapid pace. The point is, we should try to minimize as much as possible
ThisimagefoundonWikipediathatbestdescribesthe Scalable Vector Graphics , illustrates the difference between bitmap and vector images. The bitmap image is composed of a fixed set of pixels, while the vector image is composed of a fixed set of shapes. In the image, the scale of the bitmap reveals the pixels when sizing the vector image preserves the shapes.
Read the documentation for more details.