On the android website, there is a section about color drawables. Defining these drawables in xml looks like this:
<resources>
<drawable name="solid_red">#f00</drawable>
<drawable name="solid_blue">#0000ff</drawable>
<drawable name="solid_green">#f0f0</drawable>
</resources>
In the java api, they have thr following method to define rounded corners:
setCornerRadius(float radius)
Is there a way to set the rounded corners in the xml?
Use the
<shape>tag to create a drawable in XML with rounded corners. (You can do other stuff with the shape tag like define a color gradient as well).Here’s a copy of a XML file I’m using in one of my apps to create a drawable with a white background, black border and rounded corners: