I have some problems finding the documentation of the definitions of shapes in XML for Android. I would like to define a simple circle filled with a solid color in an XML File to include it into my layout files.
Sadly the Documentation on android.com does not cover the XML attributes of the Shape classes. I think I should use an ArcShape to draw a circle but there is no explanation on how to set the size, the color, or the angle needed to make a circle out of an Arc.
Here's a simple circle_background.xml for pre-material:
You can use with the attribute
'android:background="@drawable/circle_background"
in your button's layout definitionJust use
Set this as your view background
For solid circle use:
Solid with stroke:
Note: To make the
oval
shape appear as a circle, in these examples, either your view that you are using this shape as its background should be a square or you have to set theheight
andwidth
properties of the shape tag to an equal value.Look in the Android SDK samples. There are several examples in the ApiDemos project:
/ApiDemos/res/drawable/
It will look something like this for a circle with a gradient fill:
You can use VectorDrawable as below :
The above xml renders as :