Paint Class

Definition

The Paint class holds the style and color information about how to draw geometries, text and bitmaps.

[Android.Runtime.Register("android/graphics/Paint", DoNotGenerateAcw=true)]
public class Paint : Java.Lang.Object
[<Android.Runtime.Register("android/graphics/Paint", DoNotGenerateAcw=true)>]
type Paint = class
    inherit Object
Inheritance
Paint
Derived
Attributes

Remarks

The Paint class holds the style and color information about how to draw geometries, text and bitmaps.

Java documentation for android.graphics.Paint.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Paint()

Create a new paint with default settings.

Paint(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Paint(Paint)

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

Paint(PaintFlags)

Create a new paint with the specified flags.

Fields

CursorAfter
Obsolete.

Option for getTextRunCursor.

CursorAt
Obsolete.

Option for getTextRunCursor.

CursorAtOrAfter
Obsolete.

Option for getTextRunCursor.

CursorAtOrBefore
Obsolete.

Option for getTextRunCursor.

CursorBefore
Obsolete.

Option for getTextRunCursor.

EndHyphenEditInsertArmenianHyphen

An integer representing the end of the line has Armentian hyphen (U+058A).

EndHyphenEditInsertHyphen

An integer representing the end of the line has normal hyphen character (U+002D).

EndHyphenEditInsertMaqaf

An integer representing the end of the line has maqaf (Hebrew hyphen, U+05BE).

EndHyphenEditInsertUcasHyphen

An integer representing the end of the line has Canadian Syllabics hyphen (U+1400).

EndHyphenEditInsertZwjAndHyphen

An integer representing the end of the line has Zero-Width-Joiner (U+200D) followed by normal hyphen character (U+002D).

EndHyphenEditNoEdit

An integer representing the end of the line has no modification for hyphenation.

EndHyphenEditReplaceWithHyphen

An integer representing the character at the end of the line is replaced with hyphen character (U+002D).

HintingOff
Obsolete.

Font hinter option that disables font hinting.

HintingOn
Obsolete.

Font hinter option that enables font hinting.

StartHyphenEditInsertHyphen

An integer representing the starting of the line has normal hyphen character (U+002D).

StartHyphenEditInsertZwj

An integer representing the starting of the line has Zero-Width-Joiner (U+200D).

StartHyphenEditNoEdit

An integer representing the starting of the line has no modification for hyphenation.

Properties

Alpha

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

AntiAlias

Helper for getFlags(), returning true if ANTI_ALIAS_FLAG bit is set AntiAliasing smooths out the edges of what is being drawn, but is has no impact on the interior of the shape. -or- Helper for setFlags(), setting or clearing the ANTI_ALIAS_FLAG bit AntiAliasing smooths out the edges of what is being drawn, but is has no impact on the interior of the shape.

BlendMode

Get the paint's blend mode object. -or- Set or clear the blend mode.

Class

Returns the runtime class of this Object.

(Inherited from Object)
Color

Return the paint's color in sRGB. -or- Set the paint's color.

ColorFilter

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

ColorLong

Return the paint's color.

Dither

Helper for getFlags(), returning true if DITHER_FLAG bit is set Dithering affects how colors that are higher precision than the device are down-sampled. -or- Helper for setFlags(), setting or clearing the DITHER_FLAG bit Dithering affects how colors that are higher precision than the device are down-sampled.

ElegantTextHeight

Get the elegant metrics flag. -or- Set the paint's elegant height metrics flag.

EndHyphenEdit

Get the current value of end hyphen edit. -or- Set a end hyphen edit on the paint.

FakeBoldText

Helper for getFlags(), returning true if FAKE_BOLD_TEXT_FLAG bit is set -or- Helper for setFlags(), setting or clearing the FAKE_BOLD_TEXT_FLAG bit

FilterBitmap

Whether or not the bitmap filter is activated. -or- Helper for setFlags(), setting or clearing the FILTER_BITMAP_FLAG bit.

Flags

Return the paint's flags. -or- Set the paint's flags.

FontFeatureSettings

Returns the font feature settings. -or- Set font feature settings.

FontSpacing

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

FontVariationSettings

Returns the font variation settings.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
Hinting

Return the paint's hinting mode. -or- Set the paint's hinting mode.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
LetterSpacing

Return the paint's letter-spacing for text. -or- Set the paint's letter-spacing for text.

LinearText

Helper for getFlags(), returning true if LINEAR_TEXT_FLAG bit is set -or- Helper for setFlags(), setting or clearing the LINEAR_TEXT_FLAG bit

MaskFilter

Get the paint's maskfilter object.

PathEffect

Get the paint's patheffect object.

PeerReference (Inherited from Object)
Rasterizer
Obsolete.

Get the paint's rasterizer (or null).

Shader

Get the paint's shader object.

ShadowLayerColor

Returns the color of the shadow layer.

ShadowLayerColorLong

Returns the color of the shadow layer.

ShadowLayerDx

Returns the x offset of the shadow layer.

ShadowLayerDy

Returns the y offset of the shadow layer.

ShadowLayerRadius

Returns the blur radius of the shadow layer.

StartHyphenEdit

Get the current value of start hyphen edit. -or- Set a start hyphen edit on the paint.

StrikeThruPosition

Distance from top of the strike-through line to the baseline in pixels.

StrikeThruText

Helper for getFlags(), returning true if STRIKE_THRU_TEXT_FLAG bit is set -or- Helper for setFlags(), setting or clearing the STRIKE_THRU_TEXT_FLAG bit

StrikeThruThickness

Returns the thickness of the strike-through line in pixels.

StrokeCap

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

StrokeJoin

Return the paint's stroke join type. -or- Set the paint's Join.

StrokeMiter

Return the paint's stroke miter value. -or- Set the paint's stroke miter value.

StrokeWidth

Return the width for stroking. -or- Set the width for stroking.

SubpixelText

Helper for getFlags(), returning true if SUBPIXEL_TEXT_FLAG bit is set -or- Helper for setFlags(), setting or clearing the SUBPIXEL_TEXT_FLAG bit

TextAlign

Return the paint's Align value for drawing text. -or- Set the paint's text alignment.

TextLocale

Get the text's primary Locale. -or- Set the text locale list to a one-member list consisting of just the locale.

TextLocales

Get the text locale list. -or- Set the text locale list.

TextScaleX

Return the paint's horizontal scale factor for text. -or- Set the paint's horizontal scale factor for text.

TextSize

Return the paint's text size. -or- Set the paint's text size.

TextSkewX

Return the paint's horizontal skew factor for text. -or- Set the paint's horizontal skew factor for text.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Typeface

Get the paint's typeface object.

UnderlinePosition

Returns the distance from top of the underline to the baseline in pixels.

UnderlineText

Helper for getFlags(), returning true if UNDERLINE_TEXT_FLAG bit is set -or- Helper for setFlags(), setting or clearing the UNDERLINE_TEXT_FLAG bit

UnderlineThickness

Returns the thickness of the underline in pixels.

WordSpacing

Return the paint's extra word-spacing for text. -or- Set the paint's extra word-spacing for text.

Xfermode

Get the paint's transfer mode object.

Methods

Ascent()

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

BreakText(Char[], Int32, Int32, Single, Single[])

Measure the text, stopping early if the measured width exceeds maxWidth.

BreakText(ICharSequence, Int32, Int32, Boolean, Single, Single[])

Measure the text, stopping early if the measured width exceeds maxWidth.

BreakText(String, Boolean, Single, Single[])

Measure the text, stopping early if the measured width exceeds maxWidth.

BreakText(String, Int32, Int32, Boolean, Single, Single[])

Measure the text, stopping early if the measured width exceeds maxWidth.

ClearShadowLayer()

Clear the shadow layer.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Descent()

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

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
EqualsForTextMeasurement(Paint)

Returns true of the passed Paint will have the same effect on text measurement

GetFillPath(Path, Path)

Applies any/all effects (patheffect, stroking) to src, returning the result in dst.

GetFontMetrics()

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

GetFontMetrics(Paint+FontMetrics)

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

GetFontMetricsInt()

Return the font's interline spacing, given the Paint's settings for typeface, textSize, etc.

GetFontMetricsInt(Char[], Int32, Int32, Int32, Int32, Boolean, Paint+FontMetricsInt)
GetFontMetricsInt(ICharSequence, Int32, Int32, Int32, Int32, Boolean, Paint+FontMetricsInt)
GetFontMetricsInt(Paint+FontMetricsInt)

Return the font's interline spacing, given the Paint's settings for typeface, textSize, etc.

GetFontMetricsInt(String, Int32, Int32, Int32, Int32, Boolean, Paint+FontMetricsInt)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetOffsetForAdvance(Char[], Int32, Int32, Int32, Int32, Boolean, Single)

Get the character offset within the string whose position is closest to the specified horizontal position.

GetOffsetForAdvance(ICharSequence, Int32, Int32, Int32, Int32, Boolean, Single)
GetOffsetForAdvance(String, Int32, Int32, Int32, Int32, Boolean, Single)
GetRunAdvance(Char[], Int32, Int32, Int32, Int32, Boolean, Int32)

Measure cursor position within a run of text.

GetRunAdvance(ICharSequence, Int32, Int32, Int32, Int32, Boolean, Int32)
GetRunAdvance(String, Int32, Int32, Int32, Int32, Boolean, Int32)
GetRunCharacterAdvance(Char[], Int32, Int32, Int32, Int32, Boolean, Int32, Single[], Int32)

Measure the advance of each character within a run of text and also return the cursor position within the run.

GetRunCharacterAdvance(ICharSequence, Int32, Int32, Int32, Int32, Boolean, Int32, Single[], Int32)
GetRunCharacterAdvance(String, Int32, Int32, Int32, Int32, Boolean, Int32, Single[], Int32)
GetStyle()

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

GetTextBounds(Char[], Int32, Int32, Rect)

Return in bounds (allocated by the caller) the smallest rectangle that encloses all of the characters, with an implied origin at (0,0).

GetTextBounds(ICharSequence, Int32, Int32, Rect)

Retrieve the text boundary box and store to bounds.

GetTextBounds(String, Int32, Int32, Rect)

Retrieve the text boundary box and store to bounds.

GetTextPath(Char[], Int32, Int32, Single, Single, Path)

Return the path (outline) for the specified text.

GetTextPath(String, Int32, Int32, Single, Single, Path)

Return the path (outline) for the specified text.

GetTextRunAdvances(Char[], Int32, Int32, Int32, Int32, Boolean, Single[], Int32)

Retrieve the character advances of the text.

GetTextRunCursor(Char[], Int32, Int32, Boolean, Int32, Int32)

Returns the next cursor position in the run.

GetTextRunCursor(ICharSequence, Int32, Int32, Boolean, Int32, Int32)

Returns the next cursor position in the run.

GetTextRunCursor(String, Int32, Int32, Boolean, Int32, Int32)

Returns the next cursor position in the run.

GetTextWidths(Char[], Int32, Int32, Single[])

Return the advance widths for the characters in the string.

GetTextWidths(ICharSequence, Int32, Int32, Single[])

Return the advance widths for the characters in the string.

GetTextWidths(String, Int32, Int32, Single[])

Return the advance widths for the characters in the string.

GetTextWidths(String, Single[])

Return the advance widths for the characters in the string.

HasGlyph(String)

Determine whether the typeface set on the paint has a glyph supporting the string.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
MeasureText(Char[], Int32, Int32)

Return the width of the text.

MeasureText(ICharSequence, Int32, Int32)

Return the width of the text.

MeasureText(String)

Return the width of the text.

MeasureText(String, Int32, Int32)

Return the width of the text.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
Reset()

Restores the paint to its default settings.

Set(Paint)

Copy the fields from src into this paint.

SetARGB(Int32, Int32, Int32, Int32)

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

SetColor(Int64)

Set the paint's color with a ColorLong.

SetColorFilter(ColorFilter)

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

SetFontVariationSettings(String)

Sets TrueType or OpenType font variation settings.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetMaskFilter(MaskFilter)

Set or clear the maskfilter object.

SetPathEffect(PathEffect)

Set or clear the patheffect object.

SetRasterizer(Rasterizer)
Obsolete.

Set or clear the rasterizer object.

SetShader(Shader)

Set or clear the shader object.

SetShadowLayer(Single, Single, Single, Color)

This draws a shadow layer below the main layer, with the specified offset and color, and blur radius.

SetShadowLayer(Single, Single, Single, Int64)

This draws a shadow layer below the main layer, with the specified offset and color, and blur radius.

SetStyle(Paint+Style)

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

SetTypeface(Typeface)

Set or clear the typeface object.

SetXfermode(Xfermode)

Set or clear the transfer mode object.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to