You can set the following flags in the constructor, or with setFlags(int flags)
Paint.ANTI_ALIAS_FLAG
Enable antialiasing, smooths the drawing.Paint.DITHER_FLAG
Enable dithering. If color precision is higher than the device's, this will happen.Paint.EMBEDDED_BITMAP_TEXT_FLAG
Enables the use of bitmap fonts.Paint.FAKE_BOLD_TEXT_FLAG
will draw text with a fake bold effect, can be used instead of using a bold typeface. Some fonts have styled bold, fake bold won'tPaint.FILTER_BITMAP_FLAG
Affects the sampling of bitmaps when transformed.Paint.HINTING_OFF
, Paint.HINTING_ON
Toggles font hinting, see thisPaint.LINEAR_TEXT_FLAG
Disables font scaling, draw operations are scaled insteadPaint.SUBPIXEL_TEXT_FLAG
Text will be computed using subpixel accuracy.Paint.STRIKE_THRU_TEXT_FLAG
Text drawn will be strikedPaint.UNDERLINE_TEXT_FLAG
Text drawn will be underlinedYou can add a flag and remove flags like this:
Paint paint = new Paint();
paint.setFlags(paint.getFlags() | Paint.FLAG); // Add flag
paint.setFlags(paint.getFlags() & ~Paint.FLAG); // Remove flag
Trying to remove a flag that isn't there or adding a flag that is already there won't change anything. Also note that most flags can also be set using set<Flag>(boolean enabled)
, for example setAntialias(true)
.
You can use paint.reset()
to reset the paint to its default settings. The only default flag is EMBEDDED_BITMAP_TEXT_FLAG
. It will be set even if you use new Paint(0)
, you will have