Android PNG透明渐变背景图片失真问题

zz:

http://hi.baidu.com/%CE%DE%D0%C4%B1%B1%BE%A9/blog/item/e76270cdcb77bd0e00e928ea.html

 

The artefact you are seeing is known as "banding" and it is aconsequence of your display being 16bits perpixel.(OnAndroid 2.2 and lower the default pixel format is 16-bit(565/PixelFormat.OPAQUE ).)

The best way to resolve this is to add some "noise" to your imageasset in Photoshop or Paint.NET.

Alternatively you can set your window to be 32bpp with thefollowing line added to your activity'sonCreate(),between super.onCreate() and setContentView().:

    getWindow().setFormat(PixelFormat.RGBA_8888);或者PixelFormat.TRANSLUCENT

在onCreate()中直接加:

getWindow().setFormat(PixelFormat.RGBA_8888);或者PixelFormat.TRANSLUCENT 即可解决。

RGBA_8888为android的一种32位颜色格式,R,G,B,A分别用八位表示,Android默认格式是PixelFormat.OPAQUE,其是不带Alpha值的。设置之后可以看到图片的显示效果就和在PC上看到一样,不会出现带状的轮廓线了。

posted on 2012-04-13 10:34  Answer.  阅读(1225)  评论(0编辑  收藏  举报