I have a LayerDrawable which I construct with an array of Drawables of 5 Drawables.
Now let’s say in run-time I want to add another Drawable to my LayerDrawable, in response to an event. How do I do that without having to re-create the LayerDrawable, this time with an array of Drawables of 6 Drawables?
Thanks.
I have a LayerDrawable which I construct with an array of Drawables of 5
Share
After LayerDrawable is created, new Drawables can not be added to it.
See the source of LayerDrawable: array of drawables is saved in
mLayerState.mChildrenand is only set in Constructor.However,
setDrawableByLayerId(..)can be used to exchange an existing Drawable with a new one.