Marco D.
Marco D.

Reputation: 133

Changing a color resource programmatically?

I got a little circle TextView from Vicky Vicent ("Android: Creating a Circular TextView?") In my situation this one should show a Level and I would like to define the background color for certain areas by myself. How can I change this one with my Activity?

<solid android:color="#9FE554" />

Upvotes: 0

Views: 100

Answers (1)

Tarun Kumar
Tarun Kumar

Reputation: 538

To change the solid color of the xml drawable resource use the below code.

GradientDrawable bgShape = (GradientDrawable)textview.getBackground();
bgShape.setColor(Color.BLACK);

Upvotes: 1

Related Questions