How to change resource drawable stroke and background color programmatically

We can set background of Button, Layout etc., from the resource drawable with border, corner. In some cases it is also required that we need to change the background and border color of resource programmatically. 

It is quite simple and easy to change the stroke and background color of drawable with few lines of codes.

Below is the layout where i have added one simple button with border and background.

Just copy the code for resource drawable.

Finally, the code to change border and background color of resource drawable

Leave a Comment

Your email address will not be published. Required fields are marked *