我有一个场景,我需要有大量的进度条可绘制对象。我无法为所有这些创建 xml 资源,因为我希望用户选择一种颜色,然后将用于动态创建可绘制对象。下面是 xml 中的一个这样的可绘制对象,我如何以编程方式创建这个精确的可绘制对象?
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<solid android:color="@color/transparent" />
<stroke android:width="2px" android:color="@color/category_blue_stroke"/>
</shape>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<solid android:color="@color/category_blue" />
<stroke android:width="2px" android:color="@color/category_blue_stroke"/>
</shape>
</clip>
</item>
</layer-list>