I am trying to use LayerDrawable for a user interface widget and have one drawing layer with different borders than other layers, but it does not seem to work. Essentially, my code does this:
int left, top, right, bottom; Drawable d = mDrawable.findDrawableByLayerId(R.id.some_specific_layer); d.setBounds(left, top, right, bottom);
Meanwhile, xml looks like this:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle" > <solid android:color="#ff999999" /> </shape> </item> <item android:id="@id/some_specific_layer" android:drawable="@drawable/some_drawable"/>
Ideally, I would see some_drawable above the gray rectangle, with the amount of gray shown at the back, depending on the result of the calculation of the borders. But I never see any of the gray layer, and it seems because its borders are also set in some way.
EDIT
Here is the desired and expected result: 
The top image is what I want to achieve; gray corresponds to the first layer, and the gradient corresponds to the second layer with a predefined id . The actual result never shows gray.
Does anyone know if it is possible to set the borders of one LayerDrawable layer without affecting other layers?
source share