How to assign a drawable to a widgets button

hoping someone can help. Not sure if this is even possible but here goes.

I have an Android widget which consists of a single button. I want to programmatically set a drawable as the background. For example in a standard activity I might do...

Button mybutton = (Button) findViewById(;

GradientDrawable gd = new GradientDrawable();




The reason I am trying to do this is to programmatically change the colour of the widget button to a colour the user picks but also maintain the rounded corners of the button as defined in the drawable above.


Read More »

By: StackOverFlow - Wednesday, 9 January

Related Posts