I have a Button which populates a GridView using a custom adapter's call to getView(). As such, there is no .xml file for the Button.
Is there a way to programmatically round the Button?
Use a nine patch, here is an example one:

save this in your /res/drawable-mdpi/ directory with the filename btn_round.9.png
then in your java code do this:
mBtn.setBackgroundResource(R.drawable.btn_round);
because it is 9 patch wit will stretch to fit whatever content you are putting inside the button. Search for "android draw9patch" to learn more about how to create the 9 patch files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With