Using the Paint class

We've been drawing some primitives until now, but Canvas provides us with many more primitive rendering methods. We'll briefly cover some of them, but first, let's first talk about the Paint class as we haven't introduced it properly.

According to the official definition, the Paint class holds the style and color information about how to draw primitives, text, and bitmaps. If we check the examples we've been building, we created a Paint object on our class constructor or on the onCreate method, and we used it to draw primitives later on our onDraw() method. As, for instance, if we set our background Paint instance Style to Paint.Style.FILL, it'll fill the primitive, but we can change it to Paint.Style.STROKE if we only ...

Get Building Android UIs with Custom Views now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.