Lyubomyr Dutko
Lyubomyr Dutko

Reputation: 4526

Android Create Layered drawable in XML

I would like to create a drawable in XML that should include:

  1. image drawable
  2. color drawable

The color drawable provides white transparent color. So, as a result we would have image with some white transparent layer on top.

I have tried to use LayerDrawable, but it fails to be created during application launch:

<LayerDrawable xmlns:android="http://schemas.android.com/apk/res/android">
     <BitmapDrawable android:src="@drawable/button_play" />
     <ColorDrawable android:color="#80FFFFFF"/>
</LayerDrawable>

Could you please advice what is wrong here?

Thanks.

Upvotes: 3

Views: 4205

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007544

Per the Android documentation for LayerDrawable:

It can be defined in an XML file with the <layer-list> element. Each Drawable in the layer is defined in a nested <item>.

Upvotes: 4

Related Questions