I'm doing some rather basic drawing in an app I am working on, and am wondering about the 'proper' way to handle defining the Paint's attributes, such as color, etc. With strings, styles, menus, layouts, etc being separated from app logic and defined in XML, I was wondering about how to (if possible) define a Paint 'style' in XML in much the same way.
I've done a number of searches and have come up empty, which may be the answer, but was wondering about other approaches than, say:
mPaint = new Paint();
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setColor(0x80808080);
Thanks,
Paul
colors. xml is an XML file which is used to store the colors for the resources.
The Paint class holds the style and color information about how to draw geometries, text and bitmaps.
As far as I know there is no possibility to define a paint style in an Android resource XML file. What you can do though is to define the necessary values (integers, colors, etc.) in a resource XML and load them to your Paint object later manually. It is still hardcoded somehow, but at least you can define colors etc. in your resource file once and use them at different locations later. :-)
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