There are let's say simple LinearLayout . I need to programmatically output the loaded Bitmap object as the background of this LinearLayout . But I do not understand how to do it programmatically, because not one of the methods is intended for Bitmap .

If suddenly there is a question about why Bitmap on LinearLayout then the background should be on the whole screen, which I could not achieve from the ImageView . If there are alternatives, I will listen to you.

1 answer 1

If you need to install it programmatically, then try something like this.

BitmapDrawable(obj) converts Bitmap to Drawable

 LinearLayout linear = (LinearLayout) findViewById(R.id.linear1); Drawable drawable = new BitmapDrawable(getResources(), bitmap); (view).setBackgroundDrawable(drawable); 

Based on this answer

  • Thank you very much - user8978194