Issue
I am a beginner in Android Development and am trying to understand how to use PNG or vector drawable (XML
) files in my Android App. To practice, I create an App with both images below:
https://imgur.com/RWxaMGt (link to see the res repository)
The purpose was to compare the quality of both structures. The result can be viewed below:
https://i.imgur.com/jMgmsc5.png (link to see the result in the device emulator)
In my device, the image above represents a PNG file while the other (the image below with better quality) represents the vector drawable file.
My question is simple: is there some way to increase the quality of the PNG file in my device activity?
Note: I am using Kotlin and a simple ConstraintLayout
Solution
For showing high quality image you have to choose higher quality image but have to do following for loading that image in all types of devices.
Suppose you have a png
image
You have to choose the higher quality image for import like 1920 x 1080.
Then You have to use batch drawable importer to import that image into your android studio project
It will create appropriate versions of that high-quality image to show on different devices.
Use Glider for loading images it will show images effectively.
Here is link for how to use batch drawable importer:
https://akexorcist.dev/android-drawable-importer-plugin/
It will create folders and images of all sizes
xxxhdpi: 1280x1920 px
xxhdpi: 960x1600 px
xhdpi: 640x960 px
hdpi: 480x800 px
mdpi: 320x480 px
ldpi: 240x320 px
Answered By - Aviraj Patel
Answer Checked By - Clifford M. (JavaFixing Volunteer)