I have been playing with 2D graphics in Android and it was a little hard to understand how to do some things that I needed. The API documentation for some functions doesn’t really do much of explaining you exactly what each argument does and how you can use them. After a little research I was able to draw everything I needed so I am going to try to summarize what I learned.
Most of the drawing functions on Android will take a Paint object as an argument. To use it you just need to instantiate the Paint class:
1 Paint p = new Paint();
You can specify one of three drawing styles: FILL, FILL_AND_STROKE, STROKE. In a very simple scenario you might want to fill a shape using a blue color, and you could do it like this:
1 2 3 Paint p = new Paint(); p.setStyle(Paint.Style.FILL); p.setColor(Color.BLUE);