Change shape solid color at runtime inside Drawable xml used as background Change shape solid color at runtime inside Drawable xml used as background android android

Change shape solid color at runtime inside Drawable xml used as background


Found by me:

    View v = findViewById(R.id.layout_id);    LayerDrawable bgDrawable = (LayerDrawable)v.getBackground();    final GradientDrawable shape = (GradientDrawable)   bgDrawable.findDrawableByLayerId(R.id.shape_id);    shape.setColor(----);