やりたいこと
BitMapの画像データをLinearLayoutの背景として設定する
方法
まずBitmapをBitmapDrawable変換した後,LinearLayout.setBackgroundDrawableで背景として設定を行います.
Bitmap bmImg = BitmapFactory.decodeStream(is);
BitmapDrawable background = new BitmapDrawable(bmImg);
linearLayout.setBackgroundDrawable(background);
BitmapとBitmapDrawableの差
BitmapDrawableには以下の機能が備わっています.
- 透過色指定
- 画像のタイル表示
- 画像の伸縮
要するにBitmapより高機能らしいです.
この解決方法について
teratailの方で教えていただきました.私だけが解決方法を知っているのは勿体ないので,Qiitaの記事として記録させていただきました.