Search code examples
javaandroidstroke

Set stroke width and color of a shape in java


I am creating an app that you can use to design custom buttons easily by setting all the settings in the app and immediatly being able to see a preview. For the button, I use a shape and I have set that shape as the background. In the shape I have the normal android:width="" and android:color="" codes but I need to be able to change these in the app itself. I already have this for other aspects such as the corners using a drawable (see my question about that (solved) here.) I already tried things like drawable.setStroke() but this doesn't seem to work.


Solution

  • Parsing the right color using Color.parseColor("#000000") helped me. I don't know why it didn't work when I provided the color myself but atleast I fixed it.