語言

Layout.GetRangeForRect 方法

定義

找出位於指定矩形區域內的文字範圍。

[Android.Runtime.Register("getRangeForRect", "(Landroid/graphics/RectF;Landroid/text/SegmentFinder;Landroid/text/Layout$TextInclusionStrategy;)[I", "GetGetRangeForRect_Landroid_graphics_RectF_Landroid_text_SegmentFinder_Landroid_text_Layout_TextInclusionStrategy_Handler", ApiSince=34)]
public virtual int[]? GetRangeForRect(Android.Graphics.RectF area, Android.Text.SegmentFinder segmentFinder, Android.Text.Layout.ITextInclusionStrategy inclusionStrategy);
[<Android.Runtime.Register("getRangeForRect", "(Landroid/graphics/RectF;Landroid/text/SegmentFinder;Landroid/text/Layout$TextInclusionStrategy;)[I", "GetGetRangeForRect_Landroid_graphics_RectF_Landroid_text_SegmentFinder_Landroid_text_Layout_TextInclusionStrategy_Handler", ApiSince=34)>]
abstract member GetRangeForRect : Android.Graphics.RectF * Android.Text.SegmentFinder * Android.Text.Layout.ITextInclusionStrategy -> int[]
override this.GetRangeForRect : Android.Graphics.RectF * Android.Text.SegmentFinder * Android.Text.Layout.ITextInclusionStrategy -> int[]

參數

area
RectF

文字範圍將被找到的區域。 這個值不可能為零值。

segmentFinder
SegmentFinder

SegmentFinder 用於判定將視為文字段的範圍。 這個值不可能為零值。

inclusionStrategy
Layout.ITextInclusionStrategy

判斷文字段落是否位於指定區域內的策略。 這個值不可能為零值。

傳回

Int32[]

大小為 2 的整數陣列,包含文字範圍的起始(包含)與結束(排他)字元偏移,若區域內無文字區段則為 null 陣列

屬性

備註

找出位於指定矩形區域內的文字範圍。 範圍的起始點是該區域內第一個文字段的起點,範圍的結束點是該區域內最後一個文字段的結束點。

根據提供的 TextInclusionStrategy ,文字區段被視為位於該區域內。 如果一個文字段落跨越多行或多個方向的連續跑(例如一個連字號的單字),該文字段會在該行和分隔處被分割成多個片段,那麼如果該文字段的某些部分位於該區域內,則該文字段被視為該區域內。

回傳的範圍也可能包含不在指定區域內的文字區段,若這些文字區段位於該區段之間的文字區段之間。 例如,若「segment1」和「segment3」在區域內,而「segment2」不在區域內,則回傳範圍可能是「segment1 segment2 segment3」。

Android 參考資料。android.text.Layout.getRangeForRect

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於