0

I have a png with transparency that I'd like to use for the background of my layout. I need to set the background of the layout to a color, and then draw the image on top of that. Things I'd rather not do:

  1. Create a layout within my layout. Set the background of the outer layout to the color, set the background of the inner layout to the bitmap. This actually generates a warning because the inner layout doesn't do anything.

  2. Don't use a transparent png, just render the background image with the color.

Can I create an xml drawable that contains the image and the color maybe?

ManicBlowfish
  • 2,189
  • 2
  • 19
  • 29

3 Answers3

3

You need to create a layer-list drawable,

http://developer.android.com/guide/topics/resources/drawable-resource.html#LayerList

Here's another post on the topic,

overlay two images in android to set an imageview

Nimantha
  • 5,793
  • 5
  • 23
  • 56
Jeffrey Blattman
  • 21,781
  • 9
  • 77
  • 132
0

Use a Layer List, in which you place your Color as an XML Drawble on the bottom, and then your other below that.

Mimminito
  • 2,715
  • 3
  • 19
  • 26
0

Yes you can define a drawable that is made of multiple other drawables in xml: A LayerList

thaussma
  • 9,556
  • 5
  • 42
  • 45