背景として使用したい画像がありますが、それを防ぐために最初に縮小する必要がありますOutOfMemoryExceptions
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(getResources(), R.drawable.home_bkgrnd, options);
int imageHeight = options.outHeight;
int imageWidth = options.outWidth;
String imageType = options.outMimeType;
int sampleSize =1;
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
if(imageWidth > imageHeight){
sampleSize = Math.round((float)imageHeight/(float)height);
}else{
sampleSize = Math.round((float)imageWidth/(float)width);
}
options.inJustDecodeBounds = false;
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.home_bkgrnd, options);
rl.setBackgroundDrawable(bm);
しかし、引数としてビットマップを受け取らないので、レイアウトの背景をそのスケーリングされたビットマップに設定するにはどうすればよいですか?