Android 4.1 ImagView显示不了gif图片

Android JellyBean 4.1  ImagView显示不了gif图片

 

https://groups.google.com/forum/?fromgroups=#!topic/android-developers/SuBm1kAuAMw

 

It occurs only when the bitmap loaded from the GIF has the wrong density and gets auto-scaled by the framework.

 

Romain Guy
Android framework engineer

 

即当gif图片需要系统framework缩放时,android 4.1有个bug导致不能正确显示,而在之前的系统上是可以正常显示的。

 

解决方法:

 

An easy workaround is to put your GIF in drawable-nodpi/ instead and to perform the scaling use Bitmap.createScaledBitmap() (this API does not cause the bug to happen.) Alternatively you should think about using PNG instead. GIFs scaled at runtime are converted to ARGB_8888 bitmaps so you lose the benefit of low memory usage anyway.

 

即将所有gif图片放在资源 res/drawable-nodpi 目录下,这样系统不会自动缩放。

 

如需要缩放,需要调用Bitmap.createScaledBitmap() 来手工缩放。

 

总体来看,Android平台建议少用或不用gif图片,推荐png格式图片。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值