Defining a Paint style, color, etc in XML?
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
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. :-)
精彩评论