Setting the button radius programmatically in android

jjpp picture jjpp · Feb 4, 2013 · Viewed 13.8k times · Source

I have a button say myButton. I want to set the top left corner radius of the button programmatically. I'm looking for something like

myButton.setTopLeftCornerRadius(10);

I have looked for a method like 'setcornerradius' in eclipse but got nothing.

Answer

Cristian Holdunu picture Cristian Holdunu · Feb 4, 2013

the buttons use ImageResources to draw the background.

if you want to achieve rounded corners from code, not using 9-png images, you could take a look here

http://programmatic.blogs.ku.dk/2010/06/21/adding-a-background-with-rounded-corners-to-any-view/