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,258
  • 2
  • 21
  • 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
  • 6,405
  • 6
  • 28
  • 69
Jeffrey Blattman
  • 22,176
  • 9
  • 79
  • 134
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,803
  • 3
  • 21
  • 27
0

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

thaussma
  • 9,756
  • 5
  • 44
  • 46