I have a 1280x720px image in the res/drawable folder (not the drawable-hdpi, drawable-ldpi, etc. folder). But at runtime the size is 2560x1440px. How is this possible? Does android resize the images in the drawable folder?
Here is the code:
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.start_image_left);
int h = bitmap.getHeight(), w = bitmap.getWidth();
I'm testing this on a Motorola Moto G gen2.
Supported file types are PNG (preferred), JPG (acceptable), and GIF (discouraged). App icons, logos, and other graphics, such as those used in games, are well suited for this technique.
Once you import svg file into Android Studio project, you are going to see <vector> resource then just change the size as you want by width , height attributes. viewportWidth and viewportHeight is to set size for drawing on virtual canvas.
In Android Studio inside the res folder, one can find the drawable folder, layout folder, mipmap folder, values folder, etc. Among them, the drawable folder contains the different types of images used for the development of the application.
There's really no reason you should ever put a bitmap into the root drawable
directory. It should typically be used for XML drawables only. Bitmaps in the drawable
directory will essentially be handled as if they were in drawable-mdpi
(scaled up proportionally for other densities).
If your goal is to have a bitmap image that is the same pixel size on all densities, you need to put it in drawable-nodpi
. This will cause it to not be scaled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With