简体   繁体   中英

Android GIF transparent background disappears

I'm new to Android Java programming. For a project I need transparent images, which change dynamically. I have created a layout with an ImageView. And in it a small GIF USA flag GIF with a transparent background.

在此处输入图片说明

In code I connect the variable to the imageview and assign the same image to the variable from the ImageResources

ImageView image = (ImageView)convertView.findViewById(R.id.listview_image);
image.setImageResource(R.drawable.vlag);

This goes pretty well however the image is displayed with a white background. The transparency is lost. This is shown in the image below by the white background.

在此处输入图片说明

GIF over ImageView are always an issue. Use GIFImageView

And you must use it this way:

 gifImageView = (GifImageView) findViewById(R.id.gifImageView);
 gifImageView.setBytes(bytes);
 gifImageView.startAnimation();

Even it has an option to download the gif from the web.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM