| 限定符和类型 | 类 | 说明 |
|---|---|---|
static class |
Text.ConversionType |
Enumerates the conversion types.
|
static interface |
Text.EditorActionListener |
Listens for change events of an editor action.
|
static class |
Text.FontFamilyType |
Enumerates the font family types.
|
static interface |
Text.TextColorObserver |
Provides an observer to listen for text color changes in a component.
|
static interface |
Text.TextObserver |
Provides a text observer to observe text changes in a component.
|
static interface |
Text.TextSizeObserver |
Provides an observer to listen for text size changes in a component.
|
static class |
Text.TextSizeType |
Enumerates types of the text size.
|
static class |
Text.TruncationMode |
Indicates how to truncate text.
|
Component.BindStateChangedListener, Component.CanAcceptScrollListener, Component.ClickedListener, Component.ComponentStateChangedListener, Component.ContourRefreshedListener, Component.DefSpeechEventListener, Component.DoubleClickedListener, Component.DragFeedbackProvider, Component.DraggedListener, Component.DrawTask, Component.EditEventListener, Component.EstimateSizeListener, Component.EstimateSpec, Component.FadeEffectEnum, Component.FocusChangedListener, Component.ForwardHoverListener, Component.ForwardTouchListener, Component.GestureType, Component.HoverEventListener, Component.KeyEventListener, Component.LayoutDirection, Component.LayoutRefreshedListener, Component.LongClickedListener, Component.MeasureSpec, Component.MouseEventListener, Component.MousePointerStyleListener, Component.OnDragListener, Component.RotationEventListener, Component.ScaledListener, Component.ScrolledListener, Component.ShadowDevice, Component.ShadowMode, Component.ShadowSize, Component.SpeechEventListener, Component.TouchEventListener, Component.UnconsumedKeyEventListener, Component.VoiceEvent| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
AUTO_CURSOR_POSITION |
Indicates the position where the cursor is located.
|
static int |
AUTO_SCROLLING_FOREVER |
Indicates that the text will always be in auto scrolling state.
|
ACCESSIBILITY_ADAPTABLE, ACCESSIBILITY_DISABLE, ACCESSIBILITY_ENABLE, AXIS_X, AXIS_Y, CONTOUR_BACKGROUND, CONTOUR_BORDER, CONTOUR_PADDING_BORDER, DEFAULT_SCALE, DRAG_DOWN, DRAG_HORIZONTAL, DRAG_HORIZONTAL_VERTICAL, DRAG_LEFT, DRAG_RIGHT, DRAG_UP, DRAG_VERTICAL, EVENT_TYPE_COMPONENT_ACCESSIBILITY_FOCUSED, EVENT_TYPE_COMPONENT_ACCESSIBILITY_FOCUSED_CLEAR, EVENT_TYPE_COMPONENT_CLICKED, EVENT_TYPE_COMPONENT_FOCUSED, EVENT_TYPE_COMPONENT_LONG_CLICKED, EVENT_TYPE_COMPONENT_SCROLLED, EVENT_TYPE_COMPONENT_SELECTED, EVENT_TYPE_COMPONENT_TEXT_UPDATE, EVENT_TYPE_NOTICE, EVENT_TYPE_NOTIFICATION_STATE_UPDATE, EVENT_TYPE_TOAST_SHOW, EVENT_TYPE_WINDOW_STATE_UPDATE, FOCUS_ADAPTABLE, FOCUS_DISABLE, FOCUS_ENABLE, FOCUS_NEXT, FOCUS_PREVIOUS, FOCUS_SIDE_BOTTOM, FOCUS_SIDE_LEFT, FOCUS_SIDE_RIGHT, FOCUS_SIDE_TOP, HIDE, HORIZONTAL, ID_DEFAULT, INHERITED_MODE, INVISIBLE, mBackgroundElement, mCanvasForTaskOverContent, mCanvasForTaskUnderContent, mComponentParent, mContext, mDrawTaskOverContent, mDrawTaskUnderContent, mEstimateSizeListener, mForegroundElement, mForwardHoverListener, mHoverEventListener, mKeyEventListener, mMouseEventListener, mPosition, mRotationEventListener, mShadowElement, mUnconsumedKeyEventListener, OVAL_MODE, OVAL_SCROLL_BAR_MODE, POSITION_X_INDEX, POSITION_Y_INDEX, RECT_MODE, RECT_SCROLL_BAR_MODE, SCROLL_AUTO_STAGE, SCROLL_IDLE_STAGE, SCROLL_NORMAL_STAGE, UNSPECIFIED_SCROLL_BAR_MODE, VERTICAL, VISIBLE| 构造器 | 说明 |
|---|---|
Text(Context context) |
Default constructor used to create a
Text instance by using the default attribute set and style. |
Text(Context context,
AttrSet attrSet) |
A constructor used to create a
Text instance by using specified attribute set and default style
after the XML file is parsed. |
Text(Context context,
AttrSet attrSet,
String styleName) |
A constructor used to create a
Text instance by using specified attribute set and specified style
after the XML file is parsed. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
addTextObserver(Text.TextObserver observer) |
Adds the text observer
TextObserver to detect whether the text is changed. |
boolean |
adjustCursorPosition() |
Checks whether the cursor can be moved to a visible position.
|
void |
append(String text) |
Appends a text string to the existing text in a text component.
|
void |
delete(int length) |
Deletes text before the cursor.
|
void |
delete(int length,
boolean back) |
Deletes text before or after the cursor.
|
void |
delete(int length,
boolean back,
int pos) |
Deletes text from a specified position.
|
float |
getAdditionalLineSpacing() |
Obtains the extra spacing added to the height of each line in a text component.
|
Element[] |
getAroundElements() |
Obtains element objects around a text.
|
int |
getAroundElementsPadding() |
Obtains the padding between the text and element objects.
|
Element[] |
getAroundElementsRelative() |
Obtains element objects around a text.
|
int[] |
getAutoFontSizeRule() |
Obtains the rule for auto-sizing.
|
int |
getAutoFontSizeStep() |
Obtains the step for auto-sizing.
|
int |
getAutoScrollingCount() |
Obtains the auto scrolling count of a text.
|
long |
getAutoScrollingDuration() |
Obtains the auto scrolling duration of a text.
|
int |
getBaseLine(int line) |
Obtains the y-coordinate of the base line of the target line.
|
Element |
getBottomElement() |
Obtains the element at the bottom of the text.
|
Element |
getBottonElement() |
已过时。
This change is effective since API version 8. Replaced by
getBottomElement(). |
void |
getBoundingRect(int line,
Rect bounding) |
Obtains the bounding rectangle of the target line.
|
Element |
getBubbleElement() |
Obtains the
Element object of the bubble box where the cursor stays. |
int |
getBubbleHeight() |
Obtains the height of the bubble box for the text.
|
int |
getBubbleWidth() |
Obtains the width of the bubble box for the text.
|
int |
getCombinedPaddingBottom() |
Obtains the combined padding at the bottom of this text.
|
int |
getCombinedPaddingEnd() |
Obtains the combined padding at the end of this text.
|
int |
getCombinedPaddingLeft() |
Obtains the combined padding on the left side of this text.
|
int |
getCombinedPaddingRight() |
Obtains the combined padding on the right side of this text.
|
int |
getCombinedPaddingStart() |
Obtains the combined padding at the beginning of this text.
|
int |
getCombinedPaddingTop() |
Obtains the combined padding at the top of this text.
|
Element |
getCursorElement() |
Obtains the element object of the cursor in a text.
|
String |
getCustomInputMethodOptions() |
Obtains the custom input method options.
|
String |
getEditableString() |
Obtains the text in an editable text component.
|
boolean |
getEditingText(EditingCapability request,
EditingText text) |
Obtains the text that can be edited.
|
int |
getEditorAction() |
Obtains the editor action.
|
CharSequence |
getEditorActionText() |
Obtains the editor action text.
|
Element |
getEndElement() |
Obtains the end element around the text.
|
PacMap |
getExtraInputData(boolean isCreate) |
Obtains extra input data sent to the input method.
|
int |
getFadeEffectBoundaryWidth() |
Obtains the boundary width of the text's fade-effect area.
|
Font |
getFont() |
Obtains the text font.
|
Text.FontFamilyType |
getFontFamilyType() |
Obtains the font family type for this
Text. |
String |
getFontFeatures() |
Obtains the font feature settings.
|
String |
getFontVariations() |
Obtains the font variation settings.
|
String |
getHint() |
Obtains the hint text to be displayed when text is empty.
|
Color |
getHintColor() |
Obtains the color of the hint text in a text component.
|
TextLayout.HyphenationStrategy |
getHyphenationStrategy() |
Obtains the strategy of automatic hyphenation of this text.
|
InputFilter[] |
getInputFilters() |
Obtains a list of input filters.
|
LocaleProfile |
getInputMethodLocales() |
Obtains the suggested
LocaleProfile of this Text. |
int |
getInputMethodOption() |
Obtains the input method option of a text.
|
TextLayout.JustifyStrategy |
getJustifyStrategy() |
Obtains the text justification strategy.
|
Element |
getLeftElement() |
Obtains the element on the left of the text.
|
float |
getLetterSpacing() |
Obtains the spacing between text letters.
|
TextLayout.LineBreakStrategy |
getLineBreakStrategy() |
Obtains the line breaking strategy of this
Text. |
int |
getLineCount() |
Obtains the number of lines in this text.
|
int |
getLineHeight() |
Obtains the height between lines for this
Text. |
LocaleProfile |
getLocales() |
Obtains the default
LocaleProfile for this Text. |
int |
getMaxAutoFontSize() |
Obtains the maximum text size allowed for auto-sizing.
|
int |
getMaxTextHeight() |
Get max height of
Text. |
int |
getMaxTextLines() |
Obtains the maximum number of lines allowed in a text component.
|
int |
getMaxTextWidth() |
Get max width of
Text. |
int |
getMaxWidthInEms() |
Obtains the maximum width of this text, in ems.
|
int |
getMinAutoFontSize() |
Obtains the minimum text size allowed for auto-sizing.
|
int |
getMinTextHeight() |
Obtains the minimum height of this
Text. |
int |
getMinTextLines() |
Obtains the minimum number of lines in this text.
|
int |
getMinTextWidth() |
Obtains the minimum width for this
Text. |
int |
getMinWidthInEms() |
Obtains the minimum width of this text, in ems.
|
float |
getNumOfFontHeight() |
Obtains the line spacing multiplier, which provides extra spacing between lines in a text component.
|
int |
getOffsetByCoordinates(float x,
float y) |
Obtains the character offset that is closest to the specified position.
|
boolean |
getPaddingForText() |
Checks whether the text has extra padding spaces.
|
Locale |
getPrimaryLocale() |
|
RichText |
getRichText() |
Obtains the rich text displayed in a text component.
|
Element |
getRightElement() |
Obtains the element on the right of the text.
|
Color |
getSelectionColor() |
Obtains the color of the selected text.
|
int |
getSelectionEnd() |
Obtains the end of the selection edge.
|
Element |
getSelectionLeftBubbleElement() |
Obtains the
Element object displayed in the left padding area of the selected bubble box. |
int |
getSelectionLeftBubbleHeight() |
Obtains the height of the left padding area of the selected bubble box.
|
int |
getSelectionLeftBubbleWidth() |
Obtains the width of the left padding area of the selected bubble box.
|
Element |
getSelectionRightBubbleElement() |
Obtains the
Element object displayed in the right padding area of the
selected bubble box. |
int |
getSelectionRightBubbleHeight() |
Obtains the height of the right padding area of the selected bubble box.
|
int |
getSelectionRightBubbleWidth() |
Obtains the width of the right padding area of the selected bubble box.
|
int |
getSelectionStart() |
Obtains the start of the selection edge.
|
Element |
getStartElement() |
Obtains the start element around the text.
|
String |
getText() |
Obtains the text displayed in a text component.
|
int |
getTextAlignment() |
Obtains the text alignment in a text component.
|
Color |
getTextColor() |
Obtains the text color of a text component.
|
Text.ConversionType |
getTextConversion() |
Obtains the
ConversionType of this Text. |
BidiAnalyzer.BidiStrategy |
getTextDirectionStrategy() |
Obtains the text direction strategy.
|
float |
getTextHorizontalScale() |
Obtains the horizontal multiplier factor for this
Text. |
int |
getTextInputType() |
Obtains the text input type of the
Text. |
Color |
getTextShadowColor() |
Gets the color of the text shadow.
|
float |
getTextShadowOffsetX() |
Gets the horizontal offset of the text shadow.
|
float |
getTextShadowOffsetY() |
Gets the vertical offset of the text shadow.
|
float |
getTextShadowRadius() |
Gets the blur radius of the text shadow.
|
int |
getTextSize() |
Obtains the text size of a text component.
|
int |
getTextSize(Text.TextSizeType textSizeType) |
Obtains the font size of the text.
|
int |
getTextToBottomSpace() |
Obtains the distance from the bottom of the displayed text to the bottom of the text component.
|
int |
getTextToTopSpace() |
Obtains the distance from the top of the displayed text to the top of the text component.
|
Element |
getTopElement() |
Obtains the element at the top of the text.
|
Text.TruncationMode |
getTruncationMode() |
Obtains the truncation mode.
|
List<UrlRichStyle> |
getUrls() |
Obtains the list of hyperlinks in this text.
|
void |
insert(String text) |
Inserts text in the position where the cursor is located.
|
void |
insert(String text,
int pos) |
Insert text in a specified position.
|
boolean |
isAdjustInputPanel() |
Obtains whether to enable automatic text component re-layout when the input method panel pops up.
|
boolean |
isAllUpperCase() |
|
boolean |
isAutoFontSize() |
Obtains whether the text size is automatically adjusted to fill within the component.
|
boolean |
isAutoSelectEnabled() |
Obtains whether to select all the text when the text gets focus.
|
boolean |
isEditable() |
Checks whether this text is editable.
|
boolean |
isFallbackFontMetricsEnabled() |
Checks whether ascent or descent metrics are enabled for fallback fonts.
|
boolean |
isFocusedByTouch() |
Checks whether this
Text has focus when you touch it. |
boolean |
isHyperLinkClickable() |
Checks whether the hyperlinks in this text are clickable.
|
boolean |
isInputMethodActive() |
Checks whether this
Text is the target of the current input method. |
boolean |
isMultipleLine() |
Obtains whether a text is displayed in multiple lines in a text component.
|
boolean |
isScrollable() |
Obtains whether the text is scrollable in a text component.
|
boolean |
isSoftInputVisibleOnFocus() |
Checks whether the soft input will be made visible when this text gains the focus.
|
boolean |
isTextCursorVisible() |
Obtains whether the cursor is visible for an editable text component.
|
boolean |
isTextSelectable() |
Checks whether this
Text can be selected. |
int |
length() |
Obtains the text length allowed in a text component.
|
void |
lockEditingState() |
Locks the input method and starts text editing.
|
boolean |
moveToPosition(int offset) |
Moves the character to a visible position based on the specified
offset. |
boolean |
onCustomInputMethodCommand(String action,
PacMap data) |
Called by the framework to respond to a custom command from the input method.
|
void |
onLockEditingState() |
Called when the input method is locked.
|
protected void |
onRtlChanged(Component.LayoutDirection layoutDirection) |
Called when any RTL property has been changed.
|
boolean |
onTextEditorAction(int actionCode) |
Called when change events of the specified editor action are processed.
|
void |
onUnlockEditingState() |
Called when the input method is unlocked.
|
void |
removeTextObserver(Text.TextObserver observer) |
Removes the text observer
TextObserver. |
void |
setAdjustInputPanel(boolean adjust) |
Sets whether the layout should adjust resize when soft input panel pops up or hides.
|
void |
setAroundElements(Element left,
Element top,
Element right,
Element bottom) |
Sets element objects around a text.
|
void |
setAroundElementsPadding(int padding) |
Sets the padding between the text and element objects.
|
void |
setAroundElementsRelative(Element start,
Element top,
Element end,
Element bottom) |
Sets element objects around a text.
|
void |
setAutoCursorAdjustmentEnabled(boolean isAutoMove) |
Sets the cursor to move automatically.
|
void |
setAutoFontSize(boolean autoFontSize) |
Sets whether the text size is automatically adjusted to fill within the component.
|
void |
setAutoFontSize(boolean autoFontSize,
boolean userSizeFirst) |
Sets whether to adjust font size automatically to fill within the component, and whether to try the
specified font size before enabling automatic font size adaption.
|
void |
setAutoFontSizeRule(int[] preSet) |
Sets an array of all possible auto font sizes.
|
void |
setAutoFontSizeRule(int minFontSize,
int maxFontSize,
int autoFontStep) |
Sets the range and step of the auto font size.
|
void |
setAutoScrollingCount(int count) |
Sets the auto scrolling count of a text.
|
void |
setAutoScrollingDuration(long duration) |
Sets the auto scrolling duration for a long text.
|
void |
setAutoSelectEnabled(boolean isSelectAll) |
Sets whether to select all the texts when this
Text has focus. |
void |
setBubbleElement(int resId) |
Sets an
Element object for the bubble where the cursor stays. |
void |
setBubbleElement(Element element) |
Sets an
Element object for the bubble where the cursor stays. |
void |
setBubbleHeight(int height) |
Sets the height for the bubble box for the text.
|
void |
setBubbleSize(int width,
int height) |
Sets the width and height for the bubble box where the text is displayed.
|
void |
setBubbleWidth(int width) |
Sets the width for the bubble box for the text.
|
void |
setCursorElement(int resId) |
Sets a element object for the cursor in a text.
|
void |
setCursorElement(Element element) |
|
boolean |
setCursorPosition(int position) |
Set the cursor position of the text.
|
void |
setCustomInputMethodOptions(String options) |
Sets custom input method options for this
Text. |
void |
setEditable(boolean isEditable) |
Sets the editability for this text.
|
void |
setEditorActionListener(Text.EditorActionListener listener) |
Registers a listener for editor action in the component.
|
void |
setEditorActionText(CharSequence text,
int action) |
Sets the editor action text.
|
void |
setExtraInputData(PacMap data) |
Sets extra input data for this text.
|
void |
setFadeEffectBoundaryWidth(int width) |
Sets the boundary width for the text's fade-effect area.
|
void |
setFallbackFontMetricsEnabled(boolean isEnable) |
Sets whether to enable ascent or descent metrics for fallback fonts.
|
void |
setFont(Font font) |
Sets the text font.
|
void |
setFontFamilyType(Text.FontFamilyType type) |
Sets the font family for this
Text. |
void |
setFontFeatures(String settings) |
Sets the font features.
|
boolean |
setFontVariations(String variation) |
Sets the TrueType or OpenType font variation settings.
|
void |
setHint(int resId) |
Sets the hint text to display when this
Text is empty. |
void |
setHint(String hint) |
Sets the hint text to be displayed when text is empty.
|
void |
setHintColor(Color color) |
Sets the color of the hint text in a text component.
|
void |
setHyperLinkClickable(boolean isClickable) |
Sets the clickability for the hyperlinks in this text.
|
void |
setHyperLinkColor(Color color) |
Sets the color of the links in the text.
|
void |
setHyphenationStrategy(TextLayout.HyphenationStrategy strategy) |
Sets the strategy of automatic hyphenation for this text.
|
void |
setInputFilters(InputFilter[] filters) |
Sets a list of input filters for the text.
|
void |
setInputMethodLocales(LocaleProfile locales) |
Sets the suggested
LocaleProfile for this Text. |
void |
setInputMethodOption(int option) |
Sets the input method option for a text.
|
void |
setJustifyStrategy(TextLayout.JustifyStrategy strategy) |
Sets the text justification strategy.
|
void |
setLeftBubbleHeight(int height) |
Sets the height for the bubble box on the left of the text.
|
void |
setLeftBubbleSize(int width,
int height) |
Sets the width and height for the left padding area of the bubble box where the text is displayed.
|
void |
setLeftBubbleWidth(int width) |
Sets the width for the bubble box on the left of the text.
|
void |
setLetterSpacing(float spacing) |
Sets the spacing between text letters.
|
void |
setLineBreakStrategy(TextLayout.LineBreakStrategy strategy) |
Sets the line breaking strategy for this
Text. |
void |
setLineHeight(int lineHeight) |
Sets the height between lines for this
Text. |
void |
setLines(int lines) |
Sets the number of lines for this text.
|
void |
setLineSpacing(float add,
float mult) |
Sets the line spacing for a text component.
|
void |
setLocales(LocaleProfile locales) |
Sets a
LocaleProfile for drawing this text. |
void |
setMaxCharacters(int maxValue) |
Sets the maximum number of characters for this
Text. |
void |
setMaxTextHeight(int maxTextHeight) |
Set max height of Text.
|
void |
setMaxTextLines(int maxLines) |
Sets the maximum number of lines allowed in a text component.
|
void |
setMaxTextWidth(int maxTextWidth) |
Set max width of Text.
|
void |
setMaxWidthInEms(int maxEms) |
Sets the maximum width for this text, in ems.
|
void |
setMinTextHeight(int minHeight) |
Sets the minimum height for this
Text. |
void |
setMinTextLines(int minLines) |
Sets the minimum number of lines for this text.
|
void |
setMinTextWidth(int minWidth) |
Sets the minimum width for this
Text. |
void |
setMinWidthInEms(int minEms) |
Sets the minimum width for this text, in ems.
|
void |
setMultipleLine(boolean multiple) |
Sets whether a text is displayed in multiple lines in a text component.
|
void |
setPaddingForText(boolean hasPadding) |
Sets whether the text has extra padding spaces.
|
void |
setPrimaryLocale(Locale locale) |
Sets a
Locale for drawing this text. |
void |
setRichText(RichText richText) |
Sets the rich text to be displayed in a text component.
|
void |
setRightBubbleHeight(int height) |
Sets the height for the bubble box on the right of the text.
|
void |
setRightBubbleSize(int width,
int height) |
Sets the width and height for the right padding area of the bubble box where the text is displayed.
|
void |
setRightBubbleWidth(int width) |
Sets the width for the bubble box on the right of the text.
|
void |
setScrollable(boolean scrollable) |
Sets whether the text is scrollable.
|
boolean |
setSelection(int start,
int end) |
Sets the selection range of this text.
|
void |
setSelectionColor(Color color) |
Sets the color for the selected text.
|
void |
setSelectionLeftBubbleElement(int resId) |
Sets an
Element object to be displayed for the left bubble. |
void |
setSelectionLeftBubbleElement(Element element) |
Sets an
Element object to be displayed for the left bubble. |
void |
setSelectionRightBubbleElement(int resId) |
Sets an
Element object to be displayed for the right bubble. |
void |
setSelectionRightBubbleElement(Element element) |
Sets an
Element object to be displayed for the right bubble. |
void |
setSoftInputVisibleOnFocus(boolean isShow) |
Sets whether the soft input will be made visible when this text gains the focus.
|
void |
setText(int resId) |
Sets the resource ID for the text to display.
|
void |
setText(String text) |
Sets the text to be displayed in a text component.
|
void |
setTextAlignment(int textAlignment) |
Sets the text alignment in a text component.
|
void |
setTextColor(Color color) |
Sets the text color for a text component.
|
void |
setTextConversion(Text.ConversionType conversionType) |
Sets a
ConversionType for this Text. |
void |
setTextCursorVisible(boolean visible) |
Sets whether the cursor is visible for an editable text component.
|
void |
setTextDirectionStrategy(BidiAnalyzer.BidiStrategy strategy) |
Sets a text direction strategy.
|
void |
setTextHeight(int pixels) |
Sets the fixed height for this
Text. |
void |
setTextHorizontalScale(float ratio) |
Sets the horizontal multiplier factor for this
Text. |
void |
setTextInputType(int inputType) |
Sets the text input type for the
Text. |
void |
setTextSelectable(boolean isSelectable) |
Sets whether this text is selectable.
|
void |
setTextShadow(float offsetX,
float offsetY,
float radius,
Color color) |
Set the shadow for this text.
|
void |
setTextSize(int size) |
Sets a specified font size for the text.
|
void |
setTextSize(int size,
Text.TextSizeType textSizeType) |
Sets the text size for a text component with indicated text size type.
|
void |
setTextWidth(int width) |
Sets the exact width for this
Text. |
void |
setTextWidthInEms(int ems) |
Sets the width for this text, in ems.
|
void |
setTruncationMode(Text.TruncationMode mode) |
Sets the truncation mode when text content is longer than the component's width.
|
void |
startAutoScrolling() |
Starts text auto scrolling.
|
void |
stopAutoScrolling() |
Stops text auto scrolling.
|
void |
unlockEditingState() |
Unlocks the input method and ends text editing.
|
addDrawTask, addDrawTask, addScrolledListener, announceAccessibility, arrange, bindCornerMark, callOnClick, canScroll, clearFocus, createAnimatorProperty, disableFadeEffect, dispatchRestoreState, dispatchSaveState, draw, enableCornerMark, enableFadeEffect, enableSaveState, enableScrollBar, estimateSize, executeDoubleClick, executeLongClick, findComponentById, findComponentHolderById, findFocus, findNextFocusableComponent, findRequestNextFocus, getAccessibility, getAccessibilityDescription, getAlpha, getAltitude, getBackgroundElement, getBaseLine, getBottom, getBoundaryFadeEffectBottomRate, getBoundaryFadeEffectLeftRate, getBoundaryFadeEffectRightRate, getBoundaryFadeEffectTopRate, getCenterZoomFactor, getCentralScrollMode, getClickedListener, getClipEnabled, getComponentDescription, getComponentMinSize, getComponentParent, getComponentPosition, getComponentSize, getComponentStateChangedListener, getComponentTreeObserver, getContentEnable, getContentPosition, getContentPositionX, getContentPositionY, getContext, getContour, getContourRefreshedListener, getCornerMark, getDragAcceptAngle, getDraggedListener, getEditEventListener, getEstimatedHeight, getEstimatedWidth, getFadeEffectColor, getFocusable, getFocusBorderEnable, getFocusBorderPadding, getFocusBorderRadius, getFocusBorderWidth, getForegroundElement, getForegroundGravity, getForwardHoverListener, getForwardTouchListener, getGesturePriority, getHeight, getHorizontalPadding, getHorizontalPosition, getHoverEventListener, getId, getKeyEventListener, getLayoutConfig, getLayoutDirection, getLayoutDirectionResolved, getLayoutRefreshedListener, getLeft, getLocationOnScreen, getMarginBottom, getMarginLeft, getMarginRight, getMargins, getMarginsLeftAndRight, getMarginsTopAndBottom, getMarginTop, getMatrix, getMinHeight, getMinWidth, getMode, getModeResolved, getMouseEventListener, getMousePointerStyleListener, getName, getPadding, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getPivot, getPivotX, getPivotY, getResourceManager, getRight, getRotation, getRotationEventListener, getRotationSensitivity, getScale, getScaledListener, getScaleX, getScaleY, getScrollbarBackgroundColor, getScrollbarColor, getScrollbarFadingDelay, getScrollbarFadingDuration, getScrollBarMode, getScrollbarRadius, getScrollbarRoundRect, getScrollbarStartAngle, getScrollbarSweepAngle, getScrollbarThickness, getScrollState, getScrollValue, getSelfVisibleRect, getShadowColor, getSpeechEventListener, getTag, getTop, getTouchEventListener, getTransitionSymbol, getTranslation, getTranslationX, getTranslationY, getTranslationZ, getUserNextFocus, getVerticalPadding, getVerticalPosition, getVisibility, getVisibleRectOnScreen, getWidth, getWindowVisibleRect, hasFocus, hasFocusedEffect, hasOverlaps, hideFocusBorder, informConfigurationChanged, invalidate, isBoundaryFadeEffectEnable, isBoundToWindow, isClickable, isClipToContourEnabled, isComponentDisplayed, isEnabled, isFadeEffected, isFocusable, isFocused, isIdentityMatrix, isLongClickOn, isPressed, isRtl, isSaveStateEnabled, isScrollbarFadingOn, isScrollBarOn, isScrollbarOverlapEnabled, isSelected, isSoundEnable, isTouchFocusable, isVibrationEffectEnabled, notifyAccessibility, onAttributeConfigChanged, onDrag, onRestoreState, onSaveState, performScale, playSound, postLayout, refreshContour, release, removeBindStateChangedListener, removeScrolledListener, requestFocus, requestForceForwardTouchEvent, restoreComponentTreeState, saveComponentTreeState, scrollBy, scrollTo, setAccessibility, setAccessibilityDescription, setAlpha, setAltitude, setBackground, setBindStateChangedListener, setBottom, setBoundaryFadeEffectEnable, setCanAcceptScrollListener, setCenterZoomFactor, setCentralScrollMode, setClickable, setClickedListener, setClipEnabled, setClipToContourEnabled, setComponentDescription, setComponentMinSize, setComponentPosition, setComponentPosition, setComponentSize, setComponentStateChangedListener, setContentEnable, setContentPosition, setContentPositionX, setContentPositionY, setContour, setContourRefreshedListener, setDoubleClickedListener, setDragAcceptAngle, setDraggedListener, setEditEventListener, setEnabled, setEstimatedSize, setEstimateSizeListener, setFadeEffectColor, setFocusable, setFocusBorderEnable, setFocusBorderPadding, setFocusBorderRadius, setFocusBorderRadius, setFocusBorderWidth, setFocusChangedListener, setFocusedEffect, setForeground, setForegroundGravity, setForwardHoverListener, setForwardTouchListener, setGesturePriority, setHeight, setHorizontalPadding, setHorizontalPosition, setHoverEventListener, setId, setKeyEventListener, setLayoutConfig, setLayoutDirection, setLayoutRefreshedListener, setLeft, setLongClickable, setLongClickedListener, setMarginBottom, setMarginLeft, setMarginRight, setMarginsLeftAndRight, setMarginsTopAndBottom, setMarginTop, setMinHeight, setMinWidth, setMode, setMouseEventListener, setMousePointerStyleListener, setName, setOnDragListener, setPadding, setPaddingBottom, setPaddingLeft, setPaddingRelative, setPaddingRight, setPaddingTop, setPivot, setPivot, setPivotX, setPivotY, setPosition, setPositionX, setPositionY, setPressState, setRight, setRotation, setRotationEventListener, setRotationSensitivity, setScale, setScaledListener, setScaleX, setScaleY, setScrollbarBackgroundColor, setScrollbarColor, setScrollbarFadingDelay, setScrollbarFadingDuration, setScrollbarFadingEnabled, setScrollBarMode, setScrollbarOverlapEnabled, setScrollbarRadius, setScrollbarRoundRect, setScrollbarStartAngle, setScrollbarSweepAngle, setScrollbarThickness, setScrolledListener, setSelected, setShadowColor, setShadowStyle, setSoundEnable, setSpeechEventListener, setTag, setTop, setTouchEventListener, setTouchFocusable, setTransitionSymbol, setTranslation, setTranslationX, setTranslationY, setTranslationZ, setUnconsumedKeyEventListener, setUserNextFocus, setVerticalPadding, setVerticalPosition, setVibrationEffectEnabled, setVisibility, setWidth, showFocusBorder, simulateClick, simulateDrag, startDragAndDrop, subscribeVoiceEvents, unsubscribeVoiceEventspublic static final int AUTO_CURSOR_POSITION
public static final int AUTO_SCROLLING_FOREVER
public Text(Context context)
Text instance by using the default attribute set and style.context - Indicates the application context.public Text(Context context, AttrSet attrSet)
Text instance by using specified attribute set and default style
after the XML file is parsed.context - Indicates the application context.attrSet - Indicates the attribute set to be used.public Text(Context context, AttrSet attrSet, String styleName)
Text instance by using specified attribute set and specified style
after the XML file is parsed.context - Indicates the application context.attrSet - Indicates the attribute set to be used.styleName - Indicates the style name to use.public void addTextObserver(Text.TextObserver observer)
TextObserver to detect whether the text is changed.
You must implement TextObserver#onTextUpdated before using TextObserver.
observer - Indicates the text observer to add.removeTextObserver(TextObserver)public void removeTextObserver(Text.TextObserver observer)
TextObserver.observer - Indicates the text observer to remove.addTextObserver(TextObserver)public void setEditorActionListener(Text.EditorActionListener listener)
listener - Indicates the listener for editor action.public void setFont(Font font)
font - Indicates the text font.IllegalArgumentException - Throws the exception if text font is null.public Font getFont()
setFont(Font)public void setTruncationMode(Text.TruncationMode mode)
When a text component cannot show all of the text content in a single line, the following modes can be selected: (1) the start, middle, or end of the text is truncated and the truncated part is displayed as an ellipsis, (2) the text will be scrolling to display the complete content or (3) truncate directly without any special processing.
mode - Indicates the truncation mode.Text.TruncationModepublic Text.TruncationMode getTruncationMode()
TruncationMode#NONE if no mode set.setTruncationMode(TruncationMode)public void setInputMethodOption(int option)
option - Indicates the input method option of the text.InputAttribute,
getInputMethodOption()public int getInputMethodOption()
InputAttribute,
setInputMethodOption(int)public void setAutoFontSizeRule(int minFontSize,
int maxFontSize,
int autoFontStep)
The minimum font size must be smaller than the maximum font size, and the font size step must be greater than 0.
minFontSize - Indicates the minimum auto font size.maxFontSize - Indicates the maximum auto font size.autoFontStep - Indicates the auto font size step.IllegalArgumentException - Throws the exception if the min or max font size values less than 0
or step less than 0.setAutoFontSize(boolean)public void setAutoFontSizeRule(int[] preSet)
preSet - Indicates the array of all possible auto font sizes.setAutoFontSize(boolean)public int[] getAutoFontSizeRule()
setAutoFontSizeRule(int[] preSet)public boolean isAutoFontSize()
true if the text size is automatically adjusted to fill within the component;
returns false otherwise.setAutoFontSize(boolean)public int getMinAutoFontSize()
0 if auto-sizing is not configured.setAutoFontSizeRule(int, int, int)public int getMaxAutoFontSize()
0 if auto-sizing is not configured.setAutoFontSizeRule(int, int, int)public int getAutoFontSizeStep()
0 if auto-sizing is not configured.setAutoFontSizeRule(int minFontSize, int maxFontSize, int autoFontStep)public float getTextHorizontalScale()
Text.
The default horizontal multiplier factor is 1.0.
public void setTextHorizontalScale(float ratio)
Text.
The default horizontal multiplier factor is 1.0.
ratio - Indicates the horizontal multiplier factor to set.public void setTextWidth(int width)
Text.
Setting this value overrides the previous minimum or maximum width configurations.
width - Indicates the exact width to set.public void setMinTextWidth(int minWidth)
Text.minWidth - Indicates the minimum width to set.public int getMinTextWidth()
Text.Text.public void setAutoScrollingDuration(long duration)
You must use this method on a text before enabling auto scrolling. The auto scrolling
duration must be greater than or equal to 0, in milliseconds. If duration is set to 0,
the default scrolling speed is used.
duration - Indicates the auto scrolling duration of the text component.IllegalArgumentException - Throws the exception if the parameter value is less than 0.public long getAutoScrollingDuration()
0 otherwise.setAutoScrollingDuration(long)public void setAutoScrollingCount(int count)
You must use this method on a text before enabling auto scrolling.
count - Indicates the auto scrolling count of the text, which must be greater than or equal
to 1, orAUTO_SCROLLING_FOREVER, which indicates that the text component will always
be in auto scrolling state.IllegalArgumentException - Throws the exception if the parameter value is invalid.public int getAutoScrollingCount()
setAutoScrollingCount(int)public void startAutoScrolling()
public void stopAutoScrolling()
public void setCursorElement(Element element)
element - Indicates the Element object to set.public void setCursorElement(int resId)
resId - Indicates the Element resource id of the cursor in the text.public void setAutoCursorAdjustmentEnabled(boolean isAutoMove)
isAutoMove - Specifies whether the cursor will automatically move to a visible position when it
is scrolled out of sight. The value true means that the cursor will automatically move to
a visible position, and false means the opposite.public Element getCursorElement()
setCursorElement(Element)public void setAroundElements(Element left, Element top, Element right, Element bottom)
This method places element objects to the left, on the top, to the right, and at the bottom of a text. The sides of the element objects are determined by how the text is read.
Note: if element's bounds didn't set then this method set it by optimal sizes.
left - Indicates the element object to the left of the text.top - Indicates the element object on the top the text.right - Indicates the element object to the right of the text.bottom - Indicates the element object at the bottom of the text.public Element[] getAroundElements()
The element objects to the left, on the top, to the right, and at the bottom of the text are returned in sequence.
setAroundElements(Element, Element, Element, Element)public Element getLeftElement()
Elements refer to graphic materials around text.
public Element getRightElement()
Elements refer to graphic materials around text.
public Element getTopElement()
Elements refer to graphic materials around text.
@Deprecated public Element getBottonElement()
getBottomElement().Elements refer to graphic materials around text.
public Element getBottomElement()
Elements refer to graphic materials around text.
public Element getStartElement()
Elements refer to graphic materials around text.
public Element getEndElement()
Elements refer to graphic materials around text.
public void setAroundElementsRelative(Element start, Element top, Element end, Element bottom)
Note: if element's bounds didn't set then this method set it by optimal sizes.
start - Indicates the element object at the start of the text, which is to the left of the text if the
text starts from the left, or vice versa.top - Indicates the element object on the top the text.end - Indicates the element object in the end of the text, which is to the left of the text if the text
starts from the right, or vice versa.bottom - Indicates the element object at the bottom of the text.public Element[] getAroundElementsRelative()
The element objects at the start, on the top, in the end, and at the bottom of the text are returned in sequence.
setAroundElementsRelative(Element, Element, Element, Element)public void setAroundElementsPadding(int padding)
padding - Indicates the padding between the text and element objects.IllegalArgumentException - Throws the exception if the parameter value is less than 0.public int getAroundElementsPadding()
setAroundElementsPadding(int)public void setTextInputType(int inputType)
Text.inputType - Indicates the text input type, as enumerated in InputAttribute.InputAttribute,
getTextInputType()public int getTextInputType()
Text.InputAttribute.InputAttribute,
setTextInputType(int)public void setRichText(RichText richText)
A text component can display either rich text or normal text. The latest configuration will take effect.
richText - Indicates the rich text to be displayed in the text component.getRichText()public RichText getRichText()
setRichText(RichText)public void setText(String text)
text - Indicates the text to be displayed in the text component.getText(),
getEditableString()public void setText(int resId)
resId - Indicates the resource ID of the text.getText(),
getEditableString()public String getText()
setText(String)public void setHint(String hint)
hint - Indicates the hint text to be displayed when text is empty.getHint()public void setHint(int resId)
Text is empty.resId - Indicates the resource ID of the hint text.getHint()public String getHint()
setHint(String)public String getEditableString()
null is returned if the text component is
not editable.setText(String),
getText()public boolean isEditable()
true if the text is editable; returns false otherwise.setEditable(boolean)public void setTextSize(int size)
size - Indicates the font size to set.IllegalArgumentException - Throws the exception if the size parameter value is less than 0.getTextSize()public void setTextSize(int size,
Text.TextSizeType textSizeType)
size - Indicates the text size of the text component.textSizeType - Indicates the type of text size.IllegalArgumentException - Throws the exception if the size parameter value is less than 0.getTextSize(TextSizeType)public int getTextSize()
setTextSize(int)public int getTextSize(Text.TextSizeType textSizeType)
textSizeType - Indicates the unit of the text size.public void setTextColor(Color color)
color - Indicates the text color.getTextColor(),
setHintColor(Color),
getHintColor()public Color getTextColor()
setTextColor(Color),
setHintColor(Color),
getHintColor()public void setHintColor(Color color)
color - Indicates the color of the hint text in the text component.getHintColor(),
setTextColor(Color),
getTextColor()public Color getHintColor()
setHintColor(Color),
setTextColor(Color),
getTextColor()public void setTextAlignment(int textAlignment)
textAlignment - Indicates the text alignment TextAlignment in the text component.IllegalArgumentException - Throws the exception if the parameter value
doesn't corresponds to TextAlignment.getTextAlignment()public int getTextAlignment()
TextAlignment.setTextAlignment(int)public void setTextCursorVisible(boolean visible)
visible - Indicates whether the cursor is visible for an editable text
component. true indicates visible; false indicates invisible.isTextCursorVisible()public boolean isTextCursorVisible()
true if the cursor is visible for the editable text component;
returns false otherwise.setTextCursorVisible(boolean)public int length()
public void append(String text)
text - Indicates the text string to be appended.setText(String)public void insert(String text)
text - Indicates the text to insert.public void insert(String text, int pos)
pos is AUTO_CURSOR_POSITION,
the text is inserted in the position where the cursor is located.text - Indicates the text to insert.pos - Indicates the position where to insert the text. The value AUTO_CURSOR_POSITION indicates
to insert the text from the position where the cursor is located.public void delete(int length)
length - Indicates the length of the text to delete.public void delete(int length,
boolean back)
length - Indicates the length of the text to delete.back - Indicates whether to delete the text in the backward manner. true indicates to delete
the text before the cursor; false indicates to delete the text after the cursor.public void delete(int length,
boolean back,
int pos)
length - Indicates the length of the text to delete.back - Indicates whether to delete the text in the backward manner. true indicates to delete
the text before the specified position; false indicates to delete the text after the
specified position.pos - Indicates the position where to delete the text. The value AUTO_CURSOR_POSITION
indicates to delete the text from the position where the cursor is located.IllegalArgumentException - Throws the exception if the parameter value is less than 0.public void setMultipleLine(boolean multiple)
multiple - Indicates whether the text is displayed in multiple lines. true indicates
the text is displayed in multiple lines; false indicates the text is
not displayed in multiple lines.isMultipleLine(),
setMaxTextLines(int)public boolean isMultipleLine()
true if the text is displayed in multiple lines; returns false otherwise.setMultipleLine(boolean multiple),
setMaxTextLines(int)public void setMaxTextLines(int maxLines)
maxLines - Indicates the maximum number of lines allowed in the text component.IllegalArgumentException - Throws the exception if the parameter value is less than
or equals to 0.getMaxTextLines(),
setMultipleLine(boolean)public int getMaxTextLines()
setMaxTextLines(int)public void setScrollable(boolean scrollable)
scrollable - Indicates whether the text is scrollable. true indicates the text
is scrollable; false indicates the text is not scrollable.isScrollable()public boolean isScrollable()
true indicates the text is
scrollable; false indicates the text is not scrollable.true if text is scrollable; returns false otherwise.setScrollable(boolean scrollable)public void setAutoFontSize(boolean autoFontSize)
autoFontSize - Indicates whether the text size is automatically adjusted to fill within
the component. true indicates the text size is automatically adjusted to
fill within the component; false indicates the text size is not
automatically adjusted to fill within the component.isAutoFontSize()public void setAutoFontSize(boolean autoFontSize,
boolean userSizeFirst)
It is recommended that you enable autoFontSize before enabling userSizeFirst.
autoFontSize - Indicates whether to enable automatic font size adaption. true indicates
to adjust font size automatically to fill within the component, so that the complete
text content can be displayed; false indicates the opposite.userSizeFirst - userSizeFirst Indicates whether to try the specified font size before enabling
automatic font size adaption. true indicates that the specified font
size is tried for the layout. If the specified font size does not allow all the
text content to be displayed in the component, a suitable font size set
by setAutoFontSizeRule(int,int,int) will be selected. false
indicates that a suitable font size set by setAutoFontSizeRule(int,int
,int) will be used for the layout directly, without trying the specified one.setAutoFontSize(boolean)public void setLineSpacing(float add,
float mult)
Each line has its height multiplied by mult, with add added to it. For example,
when the height is 1, mult is 2, and add is 3, the line
spacing is 5.
add - Indicates the value to be added to the height of each line except for the last line.mult - Indicates the value to be multiplied by the height of each line, except for the last line.getAdditionalLineSpacing(),
getNumOfFontHeight()public float getNumOfFontHeight()
setLineSpacing(float, float),
getAdditionalLineSpacing()public float getAdditionalLineSpacing()
setLineSpacing(float, float),
getNumOfFontHeight()public boolean isAdjustInputPanel()
true if automatic text component re-layout is enabled; returns false otherwise.setAdjustInputPanel(boolean)public void setAdjustInputPanel(boolean adjust)
adjust - Indicates whether the layout should adjust resize for the editable text
component. true indicates adjust resize; false indicates not.isAdjustInputPanel()public void setMaxTextHeight(int maxTextHeight)
this method use in the situation that set Text height as MATCH_CONTENT.
maxTextHeight - Indicates the max height of Text.IllegalArgumentException - Throws the exception if the parameter value is less than 0.public int getMaxTextHeight()
Text.Text.public void setMinTextHeight(int minHeight)
Text.minHeight - Indicates the minimum height to set.public void setMaxTextWidth(int maxTextWidth)
this method use in the situation that set Text width as MATCH_CONTENT.
maxTextWidth - Indicates the max width of Text.IllegalArgumentException - Throws the exception if the parameter value is less than 0.public int getMaxTextWidth()
Text.Text.protected void onRtlChanged(Component.LayoutDirection layoutDirection)
ComponentonRtlChanged 在类中 ComponentlayoutDirection - Indicates the value of the current layout direction.public void setBubbleSize(int width,
int height)
width - Indicates the width of the bubble box to set, in pixels.height - Indicates the height of the bubble box to set, in pixels.public void setBubbleWidth(int width)
width - Indicates the width to set.public void setBubbleHeight(int height)
height - Indicates the height to set.public int getBubbleWidth()
public int getBubbleHeight()
public void setLeftBubbleSize(int width,
int height)
width - Indicates the width of the bubble box to set, in pixels.height - Indicates the height of the bubble box to set, in pixels.public void setLeftBubbleWidth(int width)
width - Indicates the width to set.public void setLeftBubbleHeight(int height)
height - Indicates the height to set.public int getSelectionLeftBubbleWidth()
public int getSelectionLeftBubbleHeight()
public void setRightBubbleSize(int width,
int height)
width - Indicates the width of the bubble box to set, in pixels.height - Indicates the height of the bubble box to set, in pixels.public void setRightBubbleWidth(int width)
width - Indicates the width to set.public void setRightBubbleHeight(int height)
height - Indicates the height to set.public int getSelectionRightBubbleWidth()
public int getSelectionRightBubbleHeight()
public void setSelectionColor(Color color)
color - Indicates the color of the selected text to set.getSelectionColor()public Color getSelectionColor()
setSelectionColor(Color)public int getSelectionStart()
public int getSelectionEnd()
public boolean setSelection(int start,
int end)
start - Indicates the start position of the selection range.end - Indicates the end position of the selection range.true if the selection range is successfully set; returns false otherwise.public void setBubbleElement(Element element)
Element object for the bubble where the cursor stays.element - Indicates the Element object to set.public void setBubbleElement(int resId)
Element object for the bubble where the cursor stays.resId - Indicates the resource ID of the element.public void setSelectionLeftBubbleElement(Element element)
Element object to be displayed for the left bubble.element - Indicates the element to display.public void setSelectionLeftBubbleElement(int resId)
Element object to be displayed for the left bubble.resId - Indicates the resource ID of the Left Bubble element.public void setSelectionRightBubbleElement(Element element)
Element object to be displayed for the right bubble.element - Indicates the element to display.public void setSelectionRightBubbleElement(int resId)
Element object to be displayed for the right bubble.resId - Indicates the resource ID of the right Bubble element.public Element getBubbleElement()
Element object of the bubble box where the cursor stays.Element object.public Element getSelectionLeftBubbleElement()
Element object displayed in the left padding area of the selected bubble box.Element object.public Element getSelectionRightBubbleElement()
Element object displayed in the right padding area of the
selected bubble box.Element object.public boolean setCursorPosition(int position)
position - The offset of the cursor position.true for successfully set, false otherwise.public void setFadeEffectBoundaryWidth(int width)
setFadeEffectBoundaryWidth 在类中 Componentwidth - Indicates the boundary width to set, in pixels.getFadeEffectBoundaryWidth()public int getFadeEffectBoundaryWidth()
getFadeEffectBoundaryWidth 在类中 ComponentsetFadeEffectBoundaryWidth(int)public void setPaddingForText(boolean hasPadding)
This method is valid only for a single line of text.
hasPadding - Specifies whether the text has extra padding spaces.
The value true indicates that the height of the text is between the top and bottom borders,
and false indicates that the height is between the font ascent and descent.public boolean getPaddingForText()
true if the height of the text is between the top and bottom borders;
returns false if the height is between the font ascent and descent.public String getFontVariations()
setFontVariations(String)public boolean setFontVariations(String variation)
The following shows sample code
for setting the font width and weight to 100.
text.setFontVariations("'wdth' 100,'wght' 100");
variation - Indicates the font variation settings.true if the passed variation is valid for the current font;
returns false if the passed variation is an empty string or does not comply
with the defined specifications.getFontVariations()public int getLineCount()
public int getLineHeight()
Text.public int getCombinedPaddingStart()
If the text starts with a component, the combined padding includes the width of the component and the component padding.
public int getCombinedPaddingTop()
If there is a component at the top of the text, the combined padding includes the height of the component and the component padding.
public int getCombinedPaddingEnd()
If there is a component at the end of the text, the combined padding includes the width of the component and the component padding.
public int getCombinedPaddingBottom()
If there is a component at the bottom of the text, the combined padding includes the height of the component and the component padding.
public int getCombinedPaddingLeft()
If there is a component on the left side of the text, the combined padding includes the width of the component and the component padding.
public int getCombinedPaddingRight()
If there is a component on the right side of the text, the combined padding includes the width of the component and the component padding.
public int getTextToTopSpace()
public int getTextToBottomSpace()
public void setHyperLinkColor(Color color)
color - The color for text link.public void setHyperLinkClickable(boolean isClickable)
isClickable - Specifies whether to set the hyperlinks to be clickable. The value true means to set
the hyperlinks to be clickable, and false means the opposite.public boolean isHyperLinkClickable()
true if the hyperlinks are clickable; returns false otherwise.public List<UrlRichStyle> getUrls()
public Locale getPrimaryLocale()
Locale for this Text.setPrimaryLocale(Locale)public void setPrimaryLocale(Locale locale)
Locale for drawing this text.locale - Indicates the Locale to set. The value cannot be null.IllegalArgumentException - Throws this exception if the value of locale is null.getPrimaryLocale()public LocaleProfile getLocales()
LocaleProfile for this Text.LocaleProfile for this Text.setLocales(LocaleProfile)public void setLocales(LocaleProfile locales)
LocaleProfile for drawing this text.locales - Indicates an array of locales. The value cannot be null.IllegalArgumentException - Throws this exception if the value of locales is null.getLocales()public LocaleProfile getInputMethodLocales()
LocaleProfile of this Text.LocaleProfile if obtained; returns null if no suggested
LocaleProfile is configured.setInputMethodLocales(LocaleProfile)public void setInputMethodLocales(LocaleProfile locales)
LocaleProfile for this Text.
When this Text has focus, the suggested locale information will be reported to the input method.
locales - Indicates the suggested LocaleProfile to set.getInputMethodLocales()public String getFontFeatures()
The format is the same as that of the CSS font-feature-settings attribute.
setFontFeatures(String)public void setFontFeatures(String settings)
The format is the same as that of the CSS font-feature-settings attribute.
settings - Indicates the font feature settings represented by a CSS-compatible string.getFontFeatures()public Color getTextShadowColor()
public void setTextShadow(float offsetX,
float offsetY,
float radius,
Color color)
offsetX - Horizontal offset of the text shadow.offsetY - Vertical offset of the text shadow.radius - Blur radius of the text shadow.color - Indicates the color of the shadow to set.public float getTextShadowOffsetX()
public float getTextShadowOffsetY()
public float getTextShadowRadius()
public void setHyphenationStrategy(TextLayout.HyphenationStrategy strategy)
strategy - Indicates the strategy of automatic hyphenation to set.TextLayout.HyphenationStrategypublic TextLayout.HyphenationStrategy getHyphenationStrategy()
TextLayout.HyphenationStrategypublic boolean moveToPosition(int offset)
offset.
This method is used to scroll the text.
If the text is not scrolled, false is returned.
offset - Indicates the offset of the character position. The offset value can only be a non-negative
integer, any negative number is treated as 0.true if the text is scrolled; returns false otherwise.public float getLetterSpacing()
public int getBaseLine(int line)
line - Indicates the target line number, ranging from 0 to the total line number minus 1. You can use
getLineCount() to obtain the total line number.public void getBoundingRect(int line,
Rect bounding)
line - Indicates the target line number, ranging from 0 to the total line number minus 1. You can use
getLineCount() to obtain the total line number.bounding - Indicates the position of the target line, including the x-coordinate on the left,
the y-coordinate on the top, the x-coordinate on the right, and the y-coordinate on the bottom.public int getMinTextHeight()
Text.Text.public void setMinTextLines(int minLines)
minLines - Indicates the minimum number of lines to set.public int getMinTextLines()
-1 otherwise.public int getOffsetByCoordinates(float x,
float y)
x - Indicates the x-coordinate of the specified position.y - Indicates the y-coordinate of specified position.public Text.FontFamilyType getFontFamilyType()
Text.Text.public void setFontFamilyType(Text.FontFamilyType type)
Text.type - Indicates the font family variant to set.public int getMaxWidthInEms()
-1 if the maximum width is not configured.public int getMinWidthInEms()
-1 if the minimum width is not configured.public void setTextWidthInEms(int ems)
ems - Indicates the width to set, in ems.public void setMaxWidthInEms(int maxEms)
maxEms - Indicates the maximum width to set, in ems.public void setMinWidthInEms(int minEms)
minEms - Indicates the minimum width to set, in ems.public TextLayout.JustifyStrategy getJustifyStrategy()
TextLayout.JustifyStrategy,
setJustifyStrategy(TextLayout.JustifyStrategy)public void setJustifyStrategy(TextLayout.JustifyStrategy strategy)
strategy - Indicates the text justification strategy.getJustifyStrategy(),
TextLayout.JustifyStrategypublic void setLetterSpacing(float spacing)
spacing - Indicates the spacing between text letters.public void setLineHeight(int lineHeight)
Text.lineHeight - Indicates the height between lines, in pixels.getLineHeight()public void setTextHeight(int pixels)
Text.pixels - Indicates the height to set, in pixels.public void setLines(int lines)
lines - Indicates the number of lines to set.public TextLayout.LineBreakStrategy getLineBreakStrategy()
Text.setLineBreakStrategy(TextLayout.LineBreakStrategy),
TextLayout.LineBreakStrategypublic void setLineBreakStrategy(TextLayout.LineBreakStrategy strategy)
Text.strategy - Indicates the line break strategy to set.getLineBreakStrategy(),
TextLayout.LineBreakStrategypublic void lockEditingState()
public void unlockEditingState()
public void onLockEditingState()
public void onUnlockEditingState()
public boolean isFocusedByTouch()
Text has focus when you touch it.true if this Text has focus; returns false otherwise.public boolean isTextSelectable()
Text can be selected.true if the text can be selected; returns false otherwise.public boolean adjustCursorPosition()
true if the cursor can be moved to a visible position; returns false otherwise.public boolean isAutoSelectEnabled()
true if all text will be selected when the text gets focus;
returns false otherwise.public void setAutoSelectEnabled(boolean isSelectAll)
Text has focus.isSelectAll - Specifies whether to select all the texts when this Text has focus.
The value true means to select all the texts, and false means the opposite.public void setTextSelectable(boolean isSelectable)
isSelectable - Specifies whether the text is selectable. The value true means that the text
is selectable, and false means the opposite.public InputFilter[] getInputFilters()
setInputFilters(ohos.agp.text.InputFilter[])public void setInputFilters(InputFilter[] filters)
filters - list of input filters.IllegalArgumentException - Throws this exception if the parameter value is null.getInputFilters()public int getEditorAction()
setEditorActionText(CharSequence, int)public CharSequence getEditorActionText()
setEditorActionText(java.lang.CharSequence, int)public void setEditorActionText(CharSequence text, int action)
When the textfield gains the focus, this information will be reported to the input method.
text - Indicates the custom editor action text sent to the input method.action - Indicates the custom editor action sent to the input method.getEditorActionText(),
getEditorAction()public void setExtraInputData(PacMap data)
When the text gains the focus, it will be reported to the input method through data.
data - Indicates the PacMap object provided to the input method.getExtraInputData(boolean)public String getCustomInputMethodOptions()
setCustomInputMethodOptions(java.lang.String)public void setCustomInputMethodOptions(String options)
Text.
If the Text is connected to an input method, the custom input method options will be sent to
the input method.
options - Indicates the custom input method options to set.getCustomInputMethodOptions()public void setTextConversion(Text.ConversionType conversionType)
ConversionType for this Text.
The conversion is used only for the text display, and will not change the text content.
conversionType - Indicates the conversion type.getTextConversion()public Text.ConversionType getTextConversion()
ConversionType.setTextConversion(ohos.agp.components.Text.ConversionType)public boolean isAllUpperCase()
true if the ConversionType is set to ConversionType#ALL_UPPERCASE;
returns false otherwise.setTextConversion(ConversionType)public boolean isInputMethodActive()
Text is the target of the current input method.true if the text is the target of the current input method; false otherwise.public boolean onTextEditorAction(int actionCode)
actionCode - Indicates the editor action. For example, InputAttribute#ENTER_KEY_TYPE_GO indicates
a "go" action, and InputAttribute#ENTER_KEY_TYPE_SEND
indicates a "send" action. For details, see InputAttribute.true if the event is processed; returns false otherwise.public boolean isSoftInputVisibleOnFocus()
The default value is true.
true if the soft input will be made visible; returns false otherwise.public void setSoftInputVisibleOnFocus(boolean isShow)
isShow - Specifies whether to make the soft input visible. The value true means to make the soft
input visible, and false means the opposite. The default value is true.public boolean getEditingText(EditingCapability request, EditingText text)
request - Indicates a request from the input method.text - Indicates the text to check.true if the editable text is obtained; returns false otherwise.public void setEditable(boolean isEditable)
isEditable - Specifies whether to set the text to be editable. The value true means to set the
text to be editable, and false means the opposite.isEditable()public PacMap getExtraInputData(boolean isCreate)
isCreate - Specifies whether to create data if the data does not exist. The value true means
to create the data, and false means the opposite.PacMap object provided to the input method if obtained;
returns null otherwise.setExtraInputData(ohos.utils.PacMap)public boolean onCustomInputMethodCommand(String action, PacMap data)
By default, this method does nothing.
action - Indicates the name of the command.data - Indicates the PacMap object for the command.true if you perform operations on the command; returns false otherwise.public void setMaxCharacters(int maxValue)
Text.maxValue - Indicates the maximum number of characters.setInputFilters(InputFilter[])public boolean isFallbackFontMetricsEnabled()
The default value is true.
true if ascent or descent metrics are enabled for fallback fonts;
returns false otherwise.public void setFallbackFontMetricsEnabled(boolean isEnable)
isEnable - Specifies whether to enable ascent or descent metrics for fallback fonts.
The value true means to enable ascent or descent metrics for fallback fonts,
and false means the opposite. The default value is true.public void setTextDirectionStrategy(BidiAnalyzer.BidiStrategy strategy)
strategy - Indicates the strategy that determines the text direction.BidiAnalyzer.BidiStrategypublic BidiAnalyzer.BidiStrategy getTextDirectionStrategy()
BidiAnalyzer.BidiStrategy