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 @Deimos's answer, but like this since some methods are deprecated now
Bitmap bmImg = BitmapFactory.decodeStream(is); BitmapDrawable background = new BitmapDrawable(context.getResources(), bmImg); linearLayout.setBackground(background);