LoginSignup
1
3

More than 5 years have passed since last update.

BitMapをLinearLayoutの背景に設定する方法(Android)

Posted at

やりたいこと

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の記事として記録させていただきました.

参考文献

BitmapDrawableの使い方

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3