写了个测试渐变图片显示的demo,关键代码如下:
myView=(ImageView)findViewById(R.id.imgView);
bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));
if(bitmap!=null){
myView.setImageBitmap(bitmap);
}编译时如果设置的sdk level为10-13(对应的android2.3-android3.1),则渐变图片可以正常显示,
如果sdk level为15(对应android4.0),则渐变图片不能正常显示,会有明显的轮廓。
查看了一些资料,说是andoird4.0默认的格式是rgb565,显示24位图片时需要设置下格式
getWindow().setFormat(PixelFormat.RGBA_8888);不过,设置了之后依然无效。求解!
myView=(ImageView)findViewById(R.id.imgView);
bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));
if(bitmap!=null){
myView.setImageBitmap(bitmap);
}编译时如果设置的sdk level为10-13(对应的android2.3-android3.1),则渐变图片可以正常显示,
如果sdk level为15(对应android4.0),则渐变图片不能正常显示,会有明显的轮廓。
查看了一些资料,说是andoird4.0默认的格式是rgb565,显示24位图片时需要设置下格式
getWindow().setFormat(PixelFormat.RGBA_8888);不过,设置了之后依然无效。求解!
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap gradient = BitmapFactory.decodeResource(getResources(), R.drawable.gradient, options);findViewById(R.id.main).setBackgroundDrawable(new BitmapDrawable(gradient));试试
不会要通过修改android底层代码才能提供支持吧?