يعمل رمز تنزيل الصور لجميع تنسيق الصورة، مشكلات مع تنسيق تنسيق PNG

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

سؤال

أنا أستخدم الرمز أدناه لتنزيل الصور وإظهارها من الخادم إلى My ImageView giveacodicetagpre.

ملف Works هذا البرنامج لجميع تنسيق الصور، ولكن عندما يتعلق الأمر ب PNG، لن يسمح للصورة شفافة بعد التنزيل والعرض على ImageView.

أي فكرة؟

هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top