Change the shape color in an Android XML

后端 未结 1 1633
小鲜肉
小鲜肉 2021-01-16 04:57

I have android drawable that I\'m going to apply to the background of several TextViews


 

        
相关标签:
1条回答
  • 2021-01-16 05:33

    It's possible to do it like this

    // "cellLabel" background colour of textview or button etc. 
    LayerDrawable layers = (LayerDrawable) cellLabel.getBackground();
    // drawable item id
    GradientDrawable shape = (GradientDrawable) (layers.findDrawableByLayerId(R.id.clr));
    shape.setColor(my_color);
    
    0 讨论(0)
提交回复
热议问题