I would like to remove/hide a layer in a layer-list during runtime. How do I do this?
I built a solution that works, but it feels a bit hackish.
I replace the desired layer with a transparent image:
LayerDrawable layerDrawable = (LayerDrawable) res.getDrawable(R.drawable.ic_layer);
Drawable digit = res.getDrawable(R.drawable.ic_number_empty);
layerDrawable.setDrawableByLayerId(R.id.layer_digit, digit);
Is there a better way to do this?
https://developer.android.com/reference/android/graphics/drawable/LayerDrawable.htmlyou could use some methods likesetAlpha(),setOpacity()orsetVisible()- GonzaloLayerListand not the individual layers. - Morgoth