您的位置:首页 > 移动开发 > Android开发

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

2012-04-13 10:34 435 查看
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上看到一样,不会出现带状的轮廓线了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: