I defined an Android Drawable like this:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="oval">
<solid android:color="@android:color/transparent" />
<stroke android:width="8dp" android:color="@android:color/white" />
</shape>
</item>
<item android:left="2dp" android:bottom="2dp" android:right="2dp" android:top="2dp">
<shape android:shape="oval">
<solid android:color="@android:color/transparent" />
<stroke android:width="4dp" android:color="@android:color/black" />
</shape>
</item>
</layer-list>
In code I get the drawable from the resources and use it while painting on a canvas (SurfaceView.draw).
Drawable dr = context.getResources().getDrawable(R.drawable.circle_empty);
@Override
public void draw(Canvas canvas) {
// how to set the color?
dr.draw(canvas);
}
But I wonder, how I could change the color of the drawable in code? For instance get a green or red ring instead of the black one as defined in XML.