I wanted to set Linear Layout background dynamically in the following way:
Fetch image from web url through XML parsing and then store that image into sd card.<
Use this:
Bitmap bmImg = BitmapFactory.decodeStream(is); BitmapDrawable background = new BitmapDrawable(bmImg); linearLayout.setBackgroundDrawable(background);
Also check this: How to convert a Bitmap to Drawable in android?