Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

やりたいこと

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の使い方

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away