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(R.id.abutton);

GradientDrawable gd = new GradientDrawable();

gd.setCornerRadius(45);

gd.setColor(Color.parseColor("#FFFFFF));

mybutton.setBackground(gd);

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.

I've...

Read More »

By: StackOverFlow - Wednesday, 9 January

Related Posts