Can a rectangle be filled with multiple colors.I mean using canvas drawrect method, a rectangle is drawn, and it is to be filled with 3(Example) colors. It can be done by drawing 3 different rectangles, but looking for some optimized solution.
Asked
Active
Viewed 862 times
0
-
try This.. [1]: http://stackoverflow.com/questions/7344497/android-canvas-draw-rectangle It might be helpful to you.. – Abhishek Patel Nov 06 '13 at 06:05
-
Thanks Abhishek for your quick responce..It works too..the link provided draws multiple rectangles with in rectangle..as i said in my question, i am looking for some other approach other than drawing multiple rectangles.. – Im Hari Nov 06 '13 at 06:14
-
1A `Canvas` is meant for drawing primitives - it literally says so in the docs. Not sure how you'd pictured to draw several rectangles (primitives) as another primitive? What makes you think it's not 'optimal'? That being said, depending on what you're trying to accomplish, you might be able leverage the [`drawVertices()`](http://goo.gl/2QlcnP) method. Not sure if that would be more 'optimal' though - most likely not from a readability/code maintenance point of view. – MH. Nov 06 '13 at 06:37