Bild-Download-Code funktioniert für alle Bildformat, Probleme mit dem PNG-Format-Rendering

StackOverflow https://stackoverflow.com/questions/5052437

Frage

Ich verwende den untenstehenden Code, um das Bild von Server auf meinen ImageView vom Server anzuzeigen. generasacodicetagpre.

Dieser Code funktioniert Datei für das gesamte Format von Bildern, aber wenn es um PNG geht, wird das Bild nach dem Download nicht transparent und auf dem ImageView angezeigt.

jede idee?

War es hilfreich?

Lösung

I dont know it will be a solution for you or not

But you can use a Drawable instead of Bitmap

Here is the code

void downloadFile(String fileUrl) {
try{
      InputStream is = (InputStream) new URL(fileUrl).getContent();
      Drawable d = Drawable.createFromStream(is, "src name");
      imgView.setImageDrawable(d);            
        } catch (IOException e) {
            e.printStackTrace();                
        }

}

This will show a png correctly

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top