androidimagepixelate

Android image from asset pixelated


While developping an Android App, I saw that all my images displayed from the assets are pixelated.

I'm using this 2 lines to display them:

Drawable imageDrawable = Drawable.createFromStream("my_logo.png", null);
imageView.setBackground(imageDrawable);

The images have as dimension: 128/128 or 256/256 and are displayed in a square ImageView.

Do anyone have an idea to keep the quality of my images ?


Solution

  • Changing the dimensions of your image can and will decrease the quality. There are a couple of things you can do

    1. Use vectors instead. Vectors can be scaled up and down infinitely without loss of quality.
    2. Use an ImageView height and width that is the same size as your image or smaller and maintains the aspect ratio.