I was looking for a way to draw a polygon, specifically a triangle, for an Android app.
I read about creating an XML file and using it in a layout for certain shapes with ShapeDrawable here, but as far as I know that only works for rectangles, ovals and rings.
I know that it's possible to draw a polygon with Path and PathShape programmatically, or to do so with OpenGL, or to draw a .png in Photoshop, but I'd much prefer a way to create one in my XML layout. Would it be possible to create a custom component to do this, for instance?
Perhaps you can extend Path and add custom XML attributes to the subclass that will construct a Path using lineTo()
. The points of the polygon can be specified as a array reference.
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