1

I am combining two images using LayerDrawable.

            Resources r = getResources();
            Drawable[] layers = new Drawable[2]; 
            layers[0] = bitMapDrawable_1;
            layers[1] = bitMapDrawable_2;
            LayerDrawable layerDrawable = new LayerDrawable(layers);

            picView.setImageDrawable(layerDrawable);

Everything is working fine, but the problem is Padding. I want to set padding on only one of the drawables, either bitMapDrawable_1 or bitMapDrawable_2.

The Two image files are :

1st Layer 2nd Layer

Now , i want this :

enter image description here

But , i m having this one :

enter image description here

BST Kaal
  • 2,993
  • 6
  • 34
  • 52
  • Thnx for response,but its not working for me. – BST Kaal May 27 '14 at 09:14
  • Because, probably, your images don't share the same SIZE in px. If one is 512*512 px, the other one also must be 512*512 px. Both must ne centered on a transparent background. When you'll overlay them, they'll mix well. The inner image "fill" must be smaller than 512px and leave a "padding" which is equal to the other image stroke. – Phantômaxx May 27 '14 at 11:25

1 Answers1

2
<LayerList>
<item paddingTop = 4dp drawable: "@drawable/bitmapDrawable_2" />
<LayerList>

In here, basicly, we are wrapping your bitmapDrawable with layerlist and using its padding attribute. Next, we are going to use this wrapper drawable.

Good luck.

Emre Aktürk
  • 3,306
  • 2
  • 18
  • 30