androidkotlinpngandroid-vectordrawable

Increasing the PNG quality in Android


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://i.sstatic.net/mKcEl.jpg (link to see the res repository)

The purpose was to compare the quality of both structures. The result can be viewed below:

https://i.sstatic.net/bL4qX.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

    1. You have to choose the higher quality image for import like 1920 x 1080.

    2. Then You have to use batch drawable importer to import that image into your android studio project

    3. It will create appropriate versions of that high-quality image to show on different devices.

    4. Use Glider for loading images it will show images effectively.

    Here is link for how to use batch drawable importer:

    https://youtu.be/toHF8fOceoc

    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