对于部分手机不显示图片。ps:在nexus5中设置较大的图片不显示。
解决方案:
在代码中实现,对图片进行压缩,然后设置为布局的背景:
@Override
protected void onResume() {
super.onResume();
RelativeLayout layout = (RelativeLayout)findViewById(R.id.main_background);
InputStream is ;
BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inPreferredConfig = Bitmap.Config.ARGB_8888;
opt.inPurgeable = true;
opt.inInputShareable = true;
opt.inSampleSize = 2;
is= getResources().openRawResource(R.drawable.app_background);
Bitmap bm = BitmapFactory.decodeStream(is, null, opt);
BitmapDrawable bd = new BitmapDrawable(getResources(), bm);
layout.setBackgroundDrawable(bd);
}