PaintCompat

public final class PaintCompat
extends Object

java.lang.Object
   ↳ androidx.core.graphics.PaintCompat


Helper for accessing features in Paint.

Summary

Public methods

static boolean hasGlyph(Paint paint, String string)

Determine whether the typeface set on the paint has a glyph supporting the string in a backwards compatible way.

static boolean setBlendMode(Paint paint, BlendModeCompat blendMode)

Configure the corresponding BlendMode on the given paint.

static boolean setBlendModeColorFilter(Paint paint, int color, BlendModeCompat blendModeCompat)

Configure the tintable color filter on the given paint.

Inherited methods

Public methods

hasGlyph

public static boolean hasGlyph (Paint paint, 
                String string)

Determine whether the typeface set on the paint has a glyph supporting the string in a backwards compatible way.

Parameters
paint Paint: the paint instance to check

string String: the string to test whether there is glyph support

Returns
boolean true if the typeface set on the given paint has a glyph for the string

setBlendMode

public static boolean setBlendMode (Paint paint, 
                BlendModeCompat blendMode)

Configure the corresponding BlendMode on the given paint. If the Android platform supports the blend mode natively, it will fall back on the framework implementation of either BlendMode or PorterDuff mode. If it is not supported then this method is a no-op

Parameters
paint Paint: target Paint to which the BlendMode will be applied

blendMode BlendModeCompat: BlendMode to configure on the paint if it is supported by the platform version. A value of null removes the BlendMode from the Paint and restores it to the default

Returns
boolean true if the specified BlendMode as applied successfully, false if the platform version does not support this BlendMode. If the BlendMode is not supported, this falls back to the default BlendMode

setBlendModeColorFilter

public static boolean setBlendModeColorFilter (Paint paint, 
                int color, 
                BlendModeCompat blendModeCompat)

Configure the tintable color filter on the given paint. If the Android platform supports the blend mode natively, it will fall back on the framework implementation of either BlendModeColorFilter or PorterDuffColorFilter. If it is not supported then this method is a no-op

Parameters
paint Paint: target Paint to which the ColorFilter will be applied

color int: color which to apply the blend mode with

blendModeCompat BlendModeCompat: BlendMode to configure on the color filter if it is supported by the platform. A value of null removes the ColorFilter from the paint

Returns
boolean true if the color filter was applied successfully with the provided BlendMode, false if the platform version does not support this BlendMode. if the BlendMode is not supported the ColorFilter is removed from the Paint