Reference:Android.graphics.Paint

From Triled Wiki

Jump to: navigation, search


android.graphics
public class android.graphics.Paint

java.lang.Object
android.graphics.Paint
The Paint class holds the style and color information about how to draw geometries, text and bitmaps.
[edit] Nested Classes
Paint.Align Align specifies how drawText aligns its text relative to the [[]x,y] coordinates.  
Paint.Cap The Cap specifies the treatment for the beginning and ending of stroked lines and paths.  
Paint.FontMetrics Class that describes the various metrics for a font at a given text size.  
Paint.FontMetricsInt Convenience method for callers that want to have FontMetrics values as integers.  
Paint.Join The Join specifies the treatment where lines and curve segments join on a stroked path.  
Paint.Style The Style specifies if the primitive being drawn is filled, stroked, or both (in the same color).  

[edit] Known Direct Subclasses

TextPaint

[edit] Summary

[edit] Constants

      Value  
int  ANTI_ALIAS_FLAG   bit mask for the flag enabling antialiasing   0x00000001 
int  DEV_KERN_TEXT_FLAG   bit mask for the flag enabling device kerning for text   256  0x00000100 
int  DITHER_FLAG   bit mask for the flag enabling dithering   0x00000004 
int  FAKE_BOLD_TEXT_FLAG   bit mask for the flag enabling fake-bold text   32  0x00000020 
int  FILTER_BITMAP_FLAG   bit mask for the flag enabling bitmap filtering   0x00000002 
int  LINEAR_TEXT_FLAG   bit mask for the flag enabling linear-text (no gridding)   64  0x00000040 
int  STRIKE_THRU_TEXT_FLAG   bit mask for the flag enabling strike-thru text   16  0x00000010 
int  SUBPIXEL_TEXT_FLAG   bit mask for the flag enabling linear-text (no gridding)   128  0x00000080 
int  UNDERLINE_TEXT_FLAG   bit mask for the flag enabling underline text   0x00000008 

[edit] Public Constructors

          Paint ()
Create a new paint with default settings.
          Paint (int flags)
Create a new paint with the specified flags.
          Paint (Paint paint)
Create a new paint, initialized with the attributes in the specified paint parameter.

[edit] Public Methods

        float  ascent ()
Return the distance above (negative) the baseline (ascent) based on the current typeface and text size.
        int  breakText (CharSequence text, int start, int end, boolean measureForwards, float maxWidth, float[] measuredWidth)
Measure the text, stopping early if the measured width exceeds maxWidth.
        int  breakText (char[] text, int index, int count, float maxWidth, float[] measuredWidth)
Measure the text, stopping early if the measured width exceeds maxWidth.
        int  breakText (String text, boolean measureForwards, float maxWidth, float[] measuredWidth)
Measure the text, stopping early if the measured width exceeds maxWidth.
        void  clearShadowLayer ()
Temporary API to clear the shadow layer.
        float  descent ()
Return the distance below (positive) the baseline (descent) based on the current typeface and text size.
        int  getAlpha ()
Helper to getColor() that just returns the color's alpha value.
        int  getColor ()
Return the paint's color.
        ColorFilter   getColorFilter ()
Get the paint's colorfilter (maybe be null).
        boolean  getFillPath (Path src, Path dst)
Applies any/all effects (patheffect, stroking) to src, returning the result in dst.
        int  getFlags ()
Return the paint's flags.
        float  getFontMetrics (FontMetrics metrics)
Return the font's recommended interline spacing, given the Paint's settings for typeface, textSize, etc.
        FontMetrics   getFontMetrics ()
Allocates a new FontMetrics object, and then calls getFontMetrics(fm) with it, returning the object.
        FontMetricsInt   getFontMetricsInt ()
        int  getFontMetricsInt (FontMetricsInt fmi)
Return the font's interline spacing, given the Paint's settings for typeface, textSize, etc.
        float  getFontSpacing ()
Return the recommend line spacing based on the current typeface and text size.
        MaskFilter   getMaskFilter ()
Get the paint's maskfilter object.
        PathEffect   getPathEffect ()
Get the paint's patheffect object.
        Rasterizer   getRasterizer ()
Get the paint's rasterizer (or null).
        Shader   getShader ()
Get the paint's shader object.
        Cap   getStrokeCap ()
Return the paint's Cap, controlling how the start and end of stroked lines and paths are treated.
        Join   getStrokeJoin ()
Return the paint's stroke join type.
        float  getStrokeMiter ()
Return the paint's stroke miter value.
        float  getStrokeWidth ()
Return the width for stroking.
        Style   getStyle ()
Return the paint's style, used for controlling how primitives' geometries are interpreted (except for drawBitmap, which always assumes FILL_STYLE).
        Align   getTextAlign ()
Return the paint's Align value for drawing text.
        void  getTextPath (String text, int start, int end, float x, float y, Path path)
Return the path (outline) for the specified text.
        void  getTextPath (char[] text, int index, int count, float x, float y, Path path)
Return the path (outline) for the specified text.
        float  getTextScaleX ()
Return the paint's horizontal scale factor for text.
        float  getTextSize ()
Return the paint's text size.
        float  getTextSkewX ()
Return the paint's horizontal skew factor for text.
        int  getTextWidths (CharSequence text, int start, int end, float[] widths)
Return the advance widths for the characters in the string.
        int  getTextWidths (char[] text, int index, int count, float[] widths)
Return the advance widths for the characters in the string.
        int  getTextWidths (String text, int start, int end, float[] widths)
Return the advance widths for the characters in the string.
        int  getTextWidths (String text, float[] widths)
Return the advance widths for the characters in the string.
        Typeface   getTypeface ()
Get the paint's typeface object.
        Xfermode   getXfermode ()
Get the paint's xfermode object.
    final    boolean  isAntiAlias ()
Helper for getFlags(), returning true if ANTI_ALIAS_FLAG bit is set
    final    boolean  isDither ()
Helper for getFlags(), returning true if DITHER_FLAG bit is set
    final    boolean  isFakeBoldText ()
Helper for getFlags(), returning true if FAKE_BOLD_TEXT_FLAG bit is set
    final    boolean  isFilterBitmap ()
Whether or not the bitmap filter is activated.
    final    boolean  isLinearText ()
Helper for getFlags(), returning true if LINEAR_TEXT_FLAG bit is set
    final    boolean  isStrikeThruText ()
Helper for getFlags(), returning true if STRIKE_THRU_TEXT_FLAG bit is set
    final    boolean  isSubpixelText ()
Helper for getFlags(), returning true if SUBPIXEL_TEXT_FLAG bit is set
    final    boolean  isUnderlineText ()
Helper for getFlags(), returning true if UNDERLINE_TEXT_FLAG bit is set
        float  measureText (char[] text, int index, int count)
Return the width of the text.
        float  measureText (String text, int start, int end)
Return the width of the text.
        float  measureText (CharSequence text, int start, int end)
Return the width of the text.
        float  measureText (String text)
Return the width of the text.
        void  reset ()
Restores the paint to its default settings.
        void  set (Paint src)
Copy the fields from src into this paint.
        void  setARGB (int a, int r, int g, int b)
Helper to setColor(), that takes a,r,g,b and constructs the color int
        void  setAlpha (int a)
Helper to setColor(), that only assigns the color's alpha value, leaving its r,g,b values unchanged.
        void  setAntiAlias (boolean aa)
Helper for setFlags(), setting or clearing the ANTI_ALIAS_FLAG bit
        void  setColor (int color)
Set the paint's color.
        ColorFilter   setColorFilter (ColorFilter filter)
Set or clear the paint's colorfilter, returning the parameter.
        void  setDither (boolean dither)
Helper for setFlags(), setting or clearing the DITHER_FLAG bit
        void  setFakeBoldText (boolean fakeBoldText)
Helper for setFlags(), setting or clearing the STRIKE_THRU_TEXT_FLAG bit
        void  setFilterBitmap (boolean filter)
Helper for setFlags(), setting or clearing the FILTER_BITMAP_FLAG bit.
        void  setFlags (int flags)
Set the paint's flags.
        void  setLinearText (boolean linearText)
Helper for setFlags(), setting or clearing the LINEAR_TEXT_FLAG bit
        MaskFilter   setMaskFilter (MaskFilter maskfilter)
Set or clear the maskfilter object.
        PathEffect   setPathEffect (PathEffect effect)
Set or clear the patheffect object.
        Rasterizer   setRasterizer (Rasterizer rasterizer)
Set or clear the rasterizer object.
        Shader   setShader (Shader shader)
Set or clear the shader object.
        void  setShadowLayer (float radius, float dx, float dy, int color)
Temporary API to expose layer drawing.
        void  setStrikeThruText (boolean strikeThruText)
Helper for setFlags(), setting or clearing the STRIKE_THRU_TEXT_FLAG bit
        void  setStrokeCap (Cap cap)
Set the paint's Cap.
        void  setStrokeJoin (Join join)
Set the paint's Join.
        void  setStrokeMiter (float miter)
Set the paint's stroke miter value.
        void  setStrokeWidth (float width)
Set the width for stroking.
        void  setStyle (Style style)
Set the paint's style, used for controlling how primitives' geometries are interpreted (except for drawBitmap, which always assumes Fill).
        void  setSubpixelText (boolean subpixelText)
Helper for setFlags(), setting or clearing the SUBPIXEL_TEXT_FLAG bit
        void  setTextAlign (Align align)
Set the paint's text alignment.
        void  setTextScaleX (float scaleX)
Set the paint's horizontal scale factor for text.
        void  setTextSize (float textSize)
Set the paint's text size.
        void  setTextSkewX (float skewX)
Set the paint's horizontal skew factor for text.
        Typeface   setTypeface (Typeface typeface)
Set or clear the typeface object.
        void  setUnderlineText (boolean underlineText)
Helper for setFlags(), setting or clearing the UNDERLINE_TEXT_FLAG bit
        Xfermode   setXfermode (Xfermode xfermode)
Set or clear the xfermode object.

[edit] Protected Methods

        void  finalize ()
Called by the virtual machine when there are no longer any (non-weak) references to the receiver.

[edit] Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

[edit] Details

[edit] Constants

[edit] public static final int ANTI_ALIAS_FLAG

bit mask for the flag enabling antialiasing Constant Value: 1 (0x00000001)

[edit] public static final int DEV_KERN_TEXT_FLAG

bit mask for the flag enabling device kerning for text Constant Value: 256 (0x00000100)

[edit] public static final int DITHER_FLAG

bit mask for the flag enabling dithering Constant Value: 4 (0x00000004)

[edit] public static final int FAKE_BOLD_TEXT_FLAG

bit mask for the flag enabling fake-bold text Constant Value: 32 (0x00000020)

[edit] public static final int FILTER_BITMAP_FLAG

bit mask for the flag enabling bitmap filtering Constant Value: 2 (0x00000002)

[edit] public static final int LINEAR_TEXT_FLAG

bit mask for the flag enabling linear-text (no gridding) Constant Value: 64 (0x00000040)

[edit] public static final int STRIKE_THRU_TEXT_FLAG

bit mask for the flag enabling strike-thru text Constant Value: 16 (0x00000010)

[edit] public static final int SUBPIXEL_TEXT_FLAG

bit mask for the flag enabling linear-text (no gridding) Constant Value: 128 (0x00000080)

[edit] public static final int UNDERLINE_TEXT_FLAG

bit mask for the flag enabling underline text Constant Value: 8 (0x00000008)

[edit] Public Constructors

[edit] public Paint()

Create a new paint with default settings.

[edit] public Paint(int flags)

Create a new paint with the specified flags. Use setFlags() to change these after the paint is created.

Parameters

flags initial flag bits, as if they were passed via setFlags().

[edit] public Paint(Paint paint)

Create a new paint, initialized with the attributes in the specified paint parameter.

Parameters

paint Existing paint used to initialized the attributes of the new paint.

[edit] Public Methods

[edit] public float ascent()

Return the distance above (negative) the baseline (ascent) based on the current typeface and text size.

Returns

  • the distance above (negative) the baseline (ascent) based on the current typeface and text size.

[edit] public int breakText(CharSequence text, int start, int end, boolean measureForwards, float maxWidth, float[] measuredWidth)

Measure the text, stopping early if the measured width exceeds maxWidth. Return the number of chars that were measured, and if measuredWidth is not null, return in it the actual width measured.

Parameters

text The text to measure
start The offset into text to begin measuring at
end The end of the text slice to measure.
measureForwards If true, measure forwards, starting at start. Otherwise, measure backwards, starting with end.
maxWidth The maximum width to accumulate.
measuredWidth Optional. If not null, returns the actual width measured.

Returns

  • The number of chars that were measured. Will always be <= abs(end - start).

[edit] public int breakText(char[] text, int index, int count, float maxWidth, float[] measuredWidth)

Measure the text, stopping early if the measured width exceeds maxWidth. Return the number of chars that were measured, and if measuredWidth is not null, return in it the actual width measured.

Parameters

text The text to measure
index The offset into text to begin measuring at
count The number of maximum number of entries to measure. If count is negative, then the characters before index are measured in reverse order. This allows for measuring the end of string.
maxWidth The maximum width to accumulate.
measuredWidth Optional. If not null, returns the actual width measured.

Returns

  • The number of chars that were measured. Will always be <= abs(count).

[edit] public int breakText(String text, boolean measureForwards, float maxWidth, float[] measuredWidth)

Measure the text, stopping early if the measured width exceeds maxWidth. Return the number of chars that were measured, and if measuredWidth is not null, return in it the actual width measured.

Parameters

text The text to measure
measureForwards If true, measure forwards, starting at index. Otherwise, measure backwards, starting with the last character in the string.
maxWidth The maximum width to accumulate.
measuredWidth Optional. If not null, returns the actual width measured.

Returns

  • The number of chars that were measured. Will always be <= abs(count).

[edit] public void clearShadowLayer()

Temporary API to clear the shadow layer.

[edit] public float descent()

Return the distance below (positive) the baseline (descent) based on the current typeface and text size.

Returns

  • the distance below (positive) the baseline (descent) based on the current typeface and text size.

[edit] public int getAlpha()

Helper to getColor() that just returns the color's alpha value. This is the same as calling getColor() >>> 24

Returns

  • the alpha component of the paint's color.

[edit] public int getColor()

Return the paint's color. Note that the color is a 32bit value containing alpha as well as r,g,b. This 32bit value is not premultiplied, meaning that its alpha can be any value, regardless of the values of r,g,b. See the Color class for more details.

Returns

  • the paint's color (and alpha).

[edit] public ColorFilter getColorFilter()

Get the paint's colorfilter (maybe be null).

Returns

  • the paint's colorfilter (maybe be null)

[edit] public boolean getFillPath(Path src, Path dst)

Applies any/all effects (patheffect, stroking) to src, returning the result in dst. The result is that drawing src with this paint will be the same as drawing dst with a default paint (at least from the geometric perspective).

Parameters

src input path
dst output path (may be the same as src)

Returns

  • true if the path should be filled, or false if it should be drawn with a hairline (width == 0)

[edit] public int getFlags()

Return the paint's flags. Use the Flag enum to test flag values.

Returns

  • the paint's flags (see enums ending in _Flag for bit masks)

[edit] public float getFontMetrics(FontMetrics metrics)

Return the font's recommended interline spacing, given the Paint's settings for typeface, textSize, etc. If metrics is not null, return the fontmetric values in it.

Parameters

metrics If this object is not null, its fields are filled with the appropriate values given the paint's text attributes.

Returns

  • the font's recommended interline spacing.

[edit] public FontMetrics getFontMetrics()

Allocates a new FontMetrics object, and then calls getFontMetrics(fm) with it, returning the object.

[edit] public FontMetricsInt getFontMetricsInt()

[edit] public int getFontMetricsInt(FontMetricsInt fmi)

Return the font's interline spacing, given the Paint's settings for typeface, textSize, etc. If metrics is not null, return the fontmetric values in it. Note: all values have been converted to integers from floats, in such a way has to make the answers useful for both spacing and clipping. If you want more control over the rounding, call getFontMetrics().

Returns

  • the font's interline spacing.

[edit] public float getFontSpacing()

Return the recommend line spacing based on the current typeface and text size.

Returns

  • recommend line spacing based on the current typeface and text size.

[edit] public MaskFilter getMaskFilter()

Get the paint's maskfilter object.

Returns

  • the paint's maskfilter (or null)

[edit] public PathEffect getPathEffect()

Get the paint's patheffect object.

Returns

  • the paint's patheffect (or null)

[edit] public Rasterizer getRasterizer()

Get the paint's rasterizer (or null).

The raster controls/modifies how paths/text are turned into alpha masks.

Returns

  • the paint's rasterizer (or null)

[edit] public Shader getShader()

Get the paint's shader object.

Returns

  • the paint's shader (or null)

[edit] public Cap getStrokeCap()

Return the paint's Cap, controlling how the start and end of stroked lines and paths are treated.

Returns

  • the line cap style for the paint, used whenever the paint's style is Stroke or StrokeAndFill.

[edit] public Join getStrokeJoin()

Return the paint's stroke join type.

Returns

  • the paint's Join.

[edit] public float getStrokeMiter()

Return the paint's stroke miter value. Used to control the behavior of miter joins when the joins angle is sharp.

Returns

  • the paint's miter limit, used whenever the paint's style is Stroke or StrokeAndFill.

[edit] public float getStrokeWidth()

Return the width for stroking.

A value of 0 strokes in hairline mode. Hairlines always draws a single pixel independent of the canva's matrix.

Returns

  • the paint's stroke width, used whenever the paint's style is Stroke or StrokeAndFill.

[edit] public Style getStyle()

Return the paint's style, used for controlling how primitives' geometries are interpreted (except for drawBitmap, which always assumes FILL_STYLE).

Returns

  • the paint's style setting (Fill, Stroke, StrokeAndFill)

[edit] public Align getTextAlign()

Return the paint's Align value for drawing text.

Returns

  • the paint's Align value for drawing text.

[edit] public void getTextPath(String text, int start, int end, float x, float y, Path path)

Return the path (outline) for the specified text. Note: just like Canvas.drawText, this will respect the Align setting in the paint.

Parameters

text The text to retrieve the path from
start The first character in the text
end 1 past the last charcter in the text
x The x coordinate of the text's origin
y The y coordinate of the text's origin
path The path to receive the data describing the text. Must be allocated by the caller.

[edit] public void getTextPath(char[] text, int index, int count, float x, float y, Path path)

Return the path (outline) for the specified text. Note: just like Canvas.drawText, this will respect the Align setting in the paint.

Parameters

text The text to retrieve the path from
index The index of the first character in text
count The number of characterss starting with index
x The x coordinate of the text's origin
y The y coordinate of the text's origin
path The path to receive the data describing the text. Must be allocated by the caller.

[edit] public float getTextScaleX()

Return the paint's horizontal scale factor for text. The default value is 1.0.

Returns

  • the paint's scale factor in X for drawing/measuring text

[edit] public float getTextSize()

Return the paint's text size.

Returns

  • the paint's text size.

[edit] public float getTextSkewX()

Return the paint's horizontal skew factor for text. The default value is 0.

Returns

  • the paint's skew factor in X for drawing text.

[edit] public int getTextWidths(CharSequence text, int start, int end, float[] widths)

Return the advance widths for the characters in the string.

Parameters

text The text to measure
start The index of the first char to to measure
end The end of the text slice to measure
widths array to receive the advance widths of the characters. Must be at least a large as (end - start).

Returns

  • the actual number of widths returned.

[edit] public int getTextWidths(char[] text, int index, int count, float[] widths)

Return the advance widths for the characters in the string.

Parameters

text The text to measure
index The index of the first char to to measure
count The number of chars starting with index to measure
widths array to receive the advance widths of the characters. Must be at least a large as count.

Returns

  • the actual number of widths returned.

[edit] public int getTextWidths(String text, int start, int end, float[] widths)

Return the advance widths for the characters in the string.

Parameters

text The text to measure
start The index of the first char to to measure
end The end of the text slice to measure
widths array to receive the advance widths of the characters. Must be at least a large as the text.

Returns

  • the number of unichars in the specified text.

[edit] public int getTextWidths(String text, float[] widths)

Return the advance widths for the characters in the string.

Parameters

text The text to measure
widths array to receive the advance widths of the characters. Must be at least a large as the text.

Returns

  • the number of unichars in the specified text.

[edit] public Typeface getTypeface()

Get the paint's typeface object.

The typeface object identifies which font to use when drawing or measuring text.

Returns

  • the paint's typeface (or null)

[edit] public Xfermode getXfermode()

Get the paint's xfermode object.

Returns

  • the paint's xfermode (or null)

[edit] public final boolean isAntiAlias()

Helper for getFlags(), returning true if ANTI_ALIAS_FLAG bit is set

Returns

  • true if the antialias bit is set in the paint's flags.

[edit] public final boolean isDither()

Helper for getFlags(), returning true if DITHER_FLAG bit is set

Returns

  • true if the dithering bit is set in the paint's flags.

[edit] public final boolean isFakeBoldText()

Helper for getFlags(), returning true if FAKE_BOLD_TEXT_FLAG bit is set

Returns

  • true if the fakeBoldText bit is set in the paint's flags.

[edit] public final boolean isFilterBitmap()

Whether or not the bitmap filter is activated.

See Also

[edit] public final boolean isLinearText()

Helper for getFlags(), returning true if LINEAR_TEXT_FLAG bit is set

Returns

  • true if the lineartext bit is set in the paint's flags

[edit] public final boolean isStrikeThruText()

Helper for getFlags(), returning true if STRIKE_THRU_TEXT_FLAG bit is set

Returns

  • true if the strikeThruText bit is set in the paint's flags.

[edit] public final boolean isSubpixelText()

Helper for getFlags(), returning true if SUBPIXEL_TEXT_FLAG bit is set

Returns

  • true if the subpixel bit is set in the paint's flags

[edit] public final boolean isUnderlineText()

Helper for getFlags(), returning true if UNDERLINE_TEXT_FLAG bit is set

Returns

  • true if the underlineText bit is set in the paint's flags.

[edit] public float measureText(char[] text, int index, int count)

Return the width of the text.

Parameters

text The text to measure
index The index of the first character to start measuring
count THe number of characters to measure, beginning with start

Returns

  • The width of the text

[edit] public float measureText(String text, int start, int end)

Return the width of the text.

Parameters

text The text to measure
start The index of the first character to start measuring
end 1 beyond the index of the last character to measure

Returns

  • The width of the text

[edit] public float measureText(CharSequence text, int start, int end)

Return the width of the text.

Parameters

text The text to measure
start The index of the first character to start measuring
end 1 beyond the index of the last character to measure

Returns

  • The width of the text

[edit] public float measureText(String text)

Return the width of the text.

Parameters

text The text to measure

Returns

  • The width of the text

[edit] public void reset()

Restores the paint to its default settings.

[edit] public void set(Paint src)

Copy the fields from src into this paint. This is equivalent to calling get() on all of the src fields, and calling the corresponding set() methods on this.

[edit] public void setARGB(int a, int r, int g, int b)

Helper to setColor(), that takes a,r,g,b and constructs the color int

Parameters

a The new alpha component (0..255) of the paint's color.
r The new red component (0..255) of the paint's color.
g The new green component (0..255) of the paint's color.
b The new blue component (0..255) of the paint's color.

[edit] public void setAlpha(int a)

Helper to setColor(), that only assigns the color's alpha value, leaving its r,g,b values unchanged.

Parameters

a set the alpha component (0..255) of the paint's color.

[edit] public void setAntiAlias(boolean aa)

Helper for setFlags(), setting or clearing the ANTI_ALIAS_FLAG bit

Parameters

aa true to set the antialias bit in the flags, false to clear it

[edit] public void setColor(int color)

Set the paint's color. Note that the color is an int containing alpha as well as r,g,b. This 32bit value is not premultiplied, meaning that its alpha can be any value, regardless of the values of r,g,b. See the Color class for more details.

Parameters

color The new color (including alpha) to set in the paint.

[edit] public ColorFilter setColorFilter(ColorFilter filter)

Set or clear the paint's colorfilter, returning the parameter.

Parameters

filter May be null. The new filter to be installed in the paint

Returns

  • filter

[edit] public void setDither(boolean dither)

Helper for setFlags(), setting or clearing the DITHER_FLAG bit

Parameters

dither true to set the dithering bit in flags, false to clear it

[edit] public void setFakeBoldText(boolean fakeBoldText)

Helper for setFlags(), setting or clearing the STRIKE_THRU_TEXT_FLAG bit

Parameters

fakeBoldText true to set the fakeBoldText bit in the paint's flags, false to clear it.

[edit] public void setFilterBitmap(boolean filter)

Helper for setFlags(), setting or clearing the FILTER_BITMAP_FLAG bit.

Parameters

filter true to set the FILTER_BITMAP_FLAG bit in the paint's flags, false to clear it.

[edit] public void setFlags(int flags)

Set the paint's flags. Use the Flag enum to specific flag values.

Parameters

flags The new flag bits for the paint

[edit] public void setLinearText(boolean linearText)

Helper for setFlags(), setting or clearing the LINEAR_TEXT_FLAG bit

Parameters

linearText true to set the linearText bit in the paint's flags, false to clear it.

[edit] public MaskFilter setMaskFilter(MaskFilter maskfilter)

Set or clear the maskfilter object.

Pass null to clear any previous maskfilter. As a convenience, the parameter passed is also returned.

Parameters

maskfilter May be null. The maskfilter to be installed in the paint

Returns

  • maskfilter

[edit] public PathEffect setPathEffect(PathEffect effect)

Set or clear the patheffect object.

Pass null to clear any previous patheffect. As a convenience, the parameter passed is also returned.

Parameters

effect May be null. The patheffect to be installed in the paint

Returns

  • effect

[edit] public Rasterizer setRasterizer(Rasterizer rasterizer)

Set or clear the rasterizer object.

Pass null to clear any previous rasterizer. As a convenience, the parameter passed is also returned.

Parameters

rasterizer May be null. The new rasterizer to be installed in the paint.

Returns

  • rasterizer

[edit] public Shader setShader(Shader shader)

Set or clear the shader object.

Pass null to clear any previous shader. As a convenience, the parameter passed is also returned.

Parameters

shader May be null. the new shader to be installed in the paint

Returns

  • shader

[edit] public void setShadowLayer(float radius, float dx, float dy, int color)

Temporary API to expose layer drawing. This draws a shadow layer below the main layer, with the specified offset and color, and blur radius. If radius is 0, then the shadow layer is removed.

[edit] public void setStrikeThruText(boolean strikeThruText)

Helper for setFlags(), setting or clearing the STRIKE_THRU_TEXT_FLAG bit

Parameters

strikeThruText true to set the strikeThruText bit in the paint's flags, false to clear it.

[edit] public void setStrokeCap(Cap cap)

Set the paint's Cap.

Parameters

cap set the paint's line cap style, used whenever the paint's style is Stroke or StrokeAndFill.

[edit] public void setStrokeJoin(Join join)

Set the paint's Join.

Parameters

join set the paint's Join, used whenever the paint's style is Stroke or StrokeAndFill.

[edit] public void setStrokeMiter(float miter)

Set the paint's stroke miter value. This is used to control the behavior of miter joins when the joins angle is sharp. This value must be >= 0.

Parameters

miter set the miter limit on the paint, used whenever the paint's style is Stroke or StrokeAndFill.

[edit] public void setStrokeWidth(float width)

Set the width for stroking. Pass 0 to stroke in hairline mode. Hairlines always draws a single pixel independent of the canva's matrix.

Parameters

width set the paint's stroke width, used whenever the paint's style is Stroke or StrokeAndFill.

[edit] public void setStyle(Style style)

Set the paint's style, used for controlling how primitives' geometries are interpreted (except for drawBitmap, which always assumes Fill).

Parameters

style The new style to set in the paint

[edit] public void setSubpixelText(boolean subpixelText)

Helper for setFlags(), setting or clearing the SUBPIXEL_TEXT_FLAG bit

Parameters

subpixelText true to set the subpixelText bit in the paint's flags, false to clear it.

[edit] public void setTextAlign(Align align)

Set the paint's text alignment.

Parameters

align set the paint's Align value for drawing text.

[edit] public void setTextScaleX(float scaleX)

Set the paint's horizontal scale factor for text. The default value is 1.0. Values > 1.0 will stretch the text wider. Values < 1.0 will stretch the text narrower.

Parameters

scaleX set the paint's scale in X for drawing/measuring text.

[edit] public void setTextSize(float textSize)

Set the paint's text size. This value must be > 0

Parameters

textSize set the paint's text size.

[edit] public void setTextSkewX(float skewX)

Set the paint's horizontal skew factor for text. The default value is 0. For approximating oblique text, use values around -0.25.

Parameters

skewX set the paint's skew factor in X for drawing text.

[edit] public Typeface setTypeface(Typeface typeface)

Set or clear the typeface object.

Pass null to clear any previous typeface. As a convenience, the parameter passed is also returned.

Parameters

typeface May be null. The typeface to be installed in the paint

Returns

  • typeface

[edit] public void setUnderlineText(boolean underlineText)

Helper for setFlags(), setting or clearing the UNDERLINE_TEXT_FLAG bit

Parameters

underlineText true to set the underlineText bit in the paint's flags, false to clear it.

[edit] public Xfermode setXfermode(Xfermode xfermode)

Set or clear the xfermode object.

Pass null to clear any previous xfermode. As a convenience, the parameter passed is also returned.

Parameters

xfermode May be null. The xfermode to be installed in the paint

Returns

  • xfermode

[edit] Protected Methods

[edit] protected void finalize()

Called by the virtual machine when there are no longer any (non-weak) references to the receiver. Subclasses can use this facility to guarantee that any associated resources are cleaned up before the receiver is garbage collected. Uncaught exceptions which are thrown during the running of the method cause it to terminate immediately, but are otherwise ignored.

Note: The virtual machine assumes that the implementation in class Object is empty.

Throws

Throwable

[edit] References

Personal tools