How to programmatically create or alter a drawable made of lines of different colors
问题 I have to draw a 3dp line to represent a level completion in a quizz game. This line must be of 2 colors. For example, if user has completed 40% of the level, the line will be red for the first 40% of the line, the other 60% being grey. I have managed to do that with a drawable : <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="line" > <size android:height="3dp" android:width="40dp"/> <stroke android