Paint.GetOffsetForAdvance Method

Definition

Overloads

GetOffsetForAdvance(String, Int32, Int32, Int32, Int32, Boolean, Single)
GetOffsetForAdvance(ICharSequence, Int32, Int32, Int32, Int32, Boolean, Single)
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(String, Int32, Int32, Int32, Int32, Boolean, Single)

public int GetOffsetForAdvance (string? text, int start, int end, int contextStart, int contextEnd, bool isRtl, float advance);
member this.GetOffsetForAdvance : string * int * int * int * int * bool * single -> int

Parameters

text
String

the text to measure. Cannot be null.

start
Int32

the index of the start of the range to measure

end
Int32

the index + 1 of the end of the range to measure

contextStart
Int32

the index of the start of the shaping context

contextEnd
Int32

the index + 1 of the end of the range to measure

isRtl
Boolean

whether the run is in RTL direction

advance
Single

width relative to start of run

Returns

index of offset

Remarks

Java documentation for android.graphics.Paint.getOffsetForAdvance(java.lang.CharSequence, int, int, int, int, boolean, float).

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.

Applies to

GetOffsetForAdvance(ICharSequence, Int32, Int32, Int32, Int32, Boolean, Single)

[Android.Runtime.Register("getOffsetForAdvance", "(Ljava/lang/CharSequence;IIIIZF)I", "GetGetOffsetForAdvance_Ljava_lang_CharSequence_IIIIZFHandler", ApiSince=23)]
public virtual int GetOffsetForAdvance (Java.Lang.ICharSequence? text, int start, int end, int contextStart, int contextEnd, bool isRtl, float advance);
[<Android.Runtime.Register("getOffsetForAdvance", "(Ljava/lang/CharSequence;IIIIZF)I", "GetGetOffsetForAdvance_Ljava_lang_CharSequence_IIIIZFHandler", ApiSince=23)>]
abstract member GetOffsetForAdvance : Java.Lang.ICharSequence * int * int * int * int * bool * single -> int
override this.GetOffsetForAdvance : Java.Lang.ICharSequence * int * int * int * int * bool * single -> int

Parameters

text
ICharSequence

the text to measure. Cannot be null.

start
Int32

the index of the start of the range to measure

end
Int32

the index + 1 of the end of the range to measure

contextStart
Int32

the index of the start of the shaping context

contextEnd
Int32

the index + 1 of the end of the range to measure

isRtl
Boolean

whether the run is in RTL direction

advance
Single

width relative to start of run

Returns

index of offset

Attributes

Remarks

Java documentation for android.graphics.Paint.getOffsetForAdvance(java.lang.CharSequence, int, int, int, int, boolean, float).

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.

Applies to

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

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

[Android.Runtime.Register("getOffsetForAdvance", "([CIIIIZF)I", "GetGetOffsetForAdvance_arrayCIIIIZFHandler", ApiSince=23)]
public virtual int GetOffsetForAdvance (char[]? text, int start, int end, int contextStart, int contextEnd, bool isRtl, float advance);
[<Android.Runtime.Register("getOffsetForAdvance", "([CIIIIZF)I", "GetGetOffsetForAdvance_arrayCIIIIZFHandler", ApiSince=23)>]
abstract member GetOffsetForAdvance : char[] * int * int * int * int * bool * single -> int
override this.GetOffsetForAdvance : char[] * int * int * int * int * bool * single -> int

Parameters

text
Char[]

the text to measure. Cannot be null.

start
Int32

the index of the start of the range to measure

end
Int32

the index + 1 of the end of the range to measure

contextStart
Int32

the index of the start of the shaping context

contextEnd
Int32

the index + 1 of the end of the range to measure

isRtl
Boolean

whether the run is in RTL direction

advance
Single

width relative to start of run

Returns

index of offset

Attributes

Remarks

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

The returned value is generally the value of offset for which #getRunAdvance yields a result most closely approximating advance, and which is also on a grapheme cluster boundary. As such, it is the preferred method for positioning a cursor in response to a touch or pointer event. The grapheme cluster boundaries are based on Unicode Standard Annex #29 but with some tailoring for better user experience.

Note that advance is a (generally positive) width measurement relative to the start of the run. Thus, for RTL runs it the distance from the point to the right edge.

All indices are relative to the start of text. Further, 0 <= contextStart <= start <= end <= contextEnd <= text.length must hold on entry, and start <= result <= end will hold on return.

Java documentation for android.graphics.Paint.getOffsetForAdvance(char[], int, int, int, int, boolean, float).

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.

Applies to