tags:

views:

62

answers:

3

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.

A: 

Not all Android classes have XML presentation. TextView for example has it has it

For your needs you can use ShapeDrawable

Orsol
I know that I can use a ShapeDrawable but how do I do it?
Janusz
http://developer.android.com/guide/topics/graphics/2d-graphics.html find there ShapeDrawable
Orsol
Thanks for the link again. But there is no Documentation on how to generate a circle in XML on this page.
Janusz
You couldn't generate a circle in XML. You need to create your own view that draws circle and then you can use it in XML.
Orsol
A: 

Just use

ShapeDrawable circle = new ShapeDrawable( new  OvalShape() );
Roflcoptr
And how can I set that as the src of an ImageView in my XML layout file?
Janusz
+1  A: 

It's not true ShapeDrawable doesn't have XML representation. Here's what you're looking for.

ognian