Android Guides | Samples

Android.Widget.TextView Class

Displays text to the user and optionally allows them to edit it.

See Also: TextView

Syntax

[Android.Runtime.Register("android/widget/TextView", DoNotGenerateAcw=true)]
public class TextView : View, ViewTreeObserver+IOnPreDrawListener, IDisposable

Remarks

Displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing; see EditText for a subclass that configures the text view for editing.

To allow users to copy some or all of the TextView's value and paste it somewhere else, set the XML attribute NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#TextView_textIsSelectable to "true" or call TextView.SetTextIsSelectable(Boolean). The textIsSelectable flag allows users to make selection gestures in the TextView, which in turn triggers the system's built-in copy/paste controls.

XML attributes

See NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#TextView, NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#View

[Android Documentation]

Requirements

Namespace: Android.Widget
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.Widget.TextView are listed below.

See Also: View

Public Constructors

Protected Constructors

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

Public Properties

AutoLinkMaskMatchOptions. Gets the autolink mask of the text.
CompoundDrawablePaddingInt32. Returns the padding between the compound drawables and the text.
[read-only]
CompoundPaddingBottomInt32. Returns the bottom padding of the view, plus space for the bottom Drawable if any.
[read-only]
CompoundPaddingEndInt32. Returns the end padding of the view, plus space for the end Drawable if any.
[read-only]
CompoundPaddingLeftInt32. Returns the left padding of the view, plus space for the left Drawable if any.
[read-only]
CompoundPaddingRightInt32. Returns the right padding of the view, plus space for the right Drawable if any.
[read-only]
CompoundPaddingStartInt32. Returns the start padding of the view, plus space for the start Drawable if any.
[read-only]
CompoundPaddingTopInt32. Returns the top padding of the view, plus space for the top Drawable if any.
[read-only]
CurrentHintTextColorColor.
[read-only]
CurrentTextColorColor.
CustomSelectionActionModeCallbackActionMode+ICallback. Retrieves the value set in TextView.CustomSelectionActionModeCallback.
[read-only]
EditableTextIEditable. Return the text the TextView is displaying as an Editable object.
EllipsizeTextUtils+TruncateAt. Returns where, if anywhere, words that are longer than the view is wide should be ellipsized.
ErrorString.
ErrorFormattedICharSequence. Returns the error message that was set to be displayed with TextView.ErrorFormatted, or null if no error was set or if it the error was cleared by the widget after user input.
[read-only]
ExtendedPaddingBottomInt32. Returns the extended bottom padding of the view, including both the bottom Drawable if any and any extra space to keep more than maxLines of text from showing.
[read-only]
ExtendedPaddingTopInt32. Returns the extended top padding of the view, including both the top Drawable if any and any extra space to keep more than maxLines of text from showing.
FontFeatureSettingsString.
FreezesTextBoolean. Return whether this text view is including its entire text contents in frozen icicles.
GravityGravityFlags. Returns the horizontal and vertical alignment of this TextView.
[read-only]
HasSelectionBoolean. Return true iff there is a selection inside this text view.
[read-only]
HighlightColorColor.
HintString.
HintFormattedICharSequence. Returns the hint that is displayed when the text of the TextView is empty.
[read-only]
HintTextColorsColorStateList.
[read-only]
ImeActionIdInt32. Get the IME action ID previous set with TextView.SetImeActionLabel(ICharSequence,ImeAction).
[read-only]
ImeActionLabelString.
[read-only]
ImeActionLabelFormattedICharSequence. Get the IME action label previous set with TextView.SetImeActionLabel(ICharSequence,ImeAction).
ImeOptionsImeAction. Get the type of the IME editor.
[read-only]
IncludeFontPaddingBoolean. Gets whether the TextView includes extra top and bottom padding to make room for accents that go above the normal ascent and descent.
InputTypeInputTypes. Get the type of the editable content.
[read-only]
IsCursorVisibleBoolean.
[read-only]
IsInputMethodTargetBoolean. Returns whether this text view is a current input method target.
[read-only]
IsSuggestionsEnabledBoolean. Return whether or not suggestions are enabled on this TextView.
[read-only]
IsTextSelectableBoolean. Returns the state of the textIsSelectable flag (See TextView.SetTextIsSelectable(Boolean)).
KeyListenerIKeyListener.
[read-only]
LayoutLayout.
LetterSpacingSingle.
[read-only]
LineCountInt32. Return the number of lines of text, or 0 if the internal Layout has not been built.
[read-only]
LineHeightInt32.
[read-only]
LineSpacingExtraSingle. Gets the line spacing extra space
[read-only]
LineSpacingMultiplierSingle. Gets the line spacing multiplier
LinksClickableBoolean. Returns whether the movement method will automatically be set to LinkMovementMethod if TextView.AutoLinkMask has been set to nonzero and links are detected in TextView.SetText(Char[],Int32,Int32).
[read-only]
LinkTextColorsColorStateList.
[read-only]
MarqueeRepeatLimitInt32. Gets the number of times the marquee animation is repeated.
[read-only]
MaxEmsInt32.
[read-only]
MaxHeightInt32.
[read-only]
MaxLinesInt32.
[read-only]
MaxWidthInt32.
[read-only]
MinEmsInt32.
[read-only]
MinHeightInt32.
[read-only]
MinLinesInt32.
[read-only]
MinWidthInt32.
MovementMethodIMovementMethod.
[read-only]
PaintTextPaint.
PaintFlagsPaintFlags.
PrivateImeOptionsString. Get the private type of the content.
[read-only]
SelectionEndInt32. Convenience for Selection.GetSelectionEnd(ICharSequence).
[read-only]
SelectionStartInt32. Convenience for Selection.GetSelectionStart(ICharSequence).
[read-only]
ShadowColorColor.
[read-only]
ShadowDxSingle.
[read-only]
ShadowDySingle.
[read-only]
ShadowRadiusSingle. Gets the radius of the shadow layer.
ShowSoftInputOnFocusBoolean. Returns whether the soft input method will be made visible when this TextView gets focused.
TextString.
[read-only]
TextColorsColorStateList. Gets the text colors for the different states (normal, selected, focused) of the TextView.
TextFormattedICharSequence. Return the text the TextView is displaying.
TextLocaleLocale. Get the default Locale of the text in this TextView.
TextScaleXSingle.
TextSizeSingle.
[read-only]
TotalPaddingBottomInt32. Returns the total bottom padding of the view, including the bottom Drawable if any, the extra space to keep more than maxLines from showing, and the vertical offset for gravity, if any.
[read-only]
TotalPaddingEndInt32. Returns the total end padding of the view, including the end Drawable if any.
[read-only]
TotalPaddingLeftInt32. Returns the total left padding of the view, including the left Drawable if any.
[read-only]
TotalPaddingRightInt32. Returns the total right padding of the view, including the right Drawable if any.
[read-only]
TotalPaddingStartInt32. Returns the total start padding of the view, including the start Drawable if any.
[read-only]
TotalPaddingTopInt32. Returns the total top padding of the view, including the top Drawable if any, the extra space to keep more than maxLines from showing, and the vertical offset for gravity, if any.
TransformationMethodITransformationMethod.
TypefaceTypeface.

Protected Properties

[read-only]
DefaultEditableBoolean. Subclasses override this to specify that they have a KeyListener by default even if not specifically called for in the XML options.
[read-only]
DefaultMovementMethodIMovementMethod. Subclasses override this to specify a default movement method.
[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

AddTextChangedListener(ITextWatcher)
Adds a TextWatcher to the list of those whose methods are called whenever this TextView's text changes.
Append(ICharSequence)
Convenience method: Append the specified text to the TextView's display buffer, upgrading it to BufferType.
Append(String)
Append(ICharSequence, Int32, Int32)
Convenience method: Append the specified text slice to the TextView's display buffer, upgrading it to BufferType.
Append(String, Int32, Int32)
BeginBatchEdit()
BringPointIntoView(Int32) : Boolean
Move the point, specified by the offset, into the view if it is needed.
ClearComposingText()
Use BaseInputConnection.RemoveComposingSpans(ISpannable) to remove any IME composing state from this text view.
Debug(Int32)
Prints information about this view in the log output, with the tag View.ViewLogTag.
DidTouchFocusSelect() : Boolean
Returns true, only while processing a touch gesture, if the initial touch down event caused focus to move to the text view and as a result its selection changed.
EndBatchEdit()
ExtractText(ExtractedTextRequest, ExtractedText) : Boolean
If this TextView contains editable content, extract a portion of it based on the information in request in to outText.
GetCompoundDrawables() : Drawable[]
Returns drawables for the left, top, right, and bottom borders.
GetCompoundDrawablesRelative() : Drawable[]
Returns drawables for the start, top, end, and bottom borders.
GetFilters() : IInputFilter[]
Returns the current list of input filters.
GetInputExtras(Boolean) : Bundle
Retrieve the input extras currently associated with the text view, which can be viewed as well as modified.
GetLineBounds(Int32, Rect) : Int32
Return the baseline for the specified line (0...getLineCount() - 1) If bounds is not null, return the top, left, right, bottom extents of the specified line in it.
GetOffsetForPosition(Single, Single) : Int32
Get the character offset closest to the specified absolute position.
static
GetTextColor(Context, TypedArray, Int32) : Color
static
GetTextColor(Context, TypedArray, Int32) : Int32
Returns the default color from the TextView_textColor attribute from the AttributeSet, if set, or the default color from the TextAppearance_textColor from the TextView_textAppearance attribute, if TextView_textColor was not set directly.
static
GetTextColors(Context, TypedArray) : ColorStateList
Returns the TextView_textColor attribute from the TypedArray, if set, or the TextAppearance_textColor from the TextView_textAppearance attribute, if TextView_textColor was not set directly.
GetUrls() : URLSpan[]
Returns the list of URLSpans attached to the text (by Linkify or otherwise) if any.
Length() : Int32
Returns the length, in characters, of the text managed by this TextView
MoveCursorToVisibleOffset() : Boolean
Move the cursor, if needed, so that it is at an offset that is visible to the user.
OnBeginBatchEdit()
Called by the framework in response to a request to begin a batch of edit operations through a call to link TextView.BeginBatchEdit.
OnCommitCompletion(CompletionInfo)
Called by the framework in response to a text completion from the current input method, provided by it calling Android.Views.InputMethods.InputConnection.commitCompletion(android.view.inputmethod.CompletionInfo).
OnCommitCorrection(CorrectionInfo)
Called by the framework in response to a text auto-correction (such as fixing a typo using a a dictionnary) from the current input method, provided by it calling Android.Views.InputMethods.InputConnection.commitCorrection(android.view.inputmethod.CorrectionInfo) InputConnection.commitCorrection()}.
OnEditorAction(ImeAction)
Called when an attached input method calls BaseInputConnection.PerformEditorAction for this text view.
OnEndBatchEdit()
Called by the framework in response to a request to end a batch of edit operations through a call to link TextView.EndBatchEdit.
OnPreDraw() : Boolean
Callback method to be invoked when the view tree is about to be drawn.
OnPrivateIMECommand(String, Bundle) : Boolean
Called by the framework in response to a private command from the current method, provided by it calling Android.Views.InputMethods.InputConnection.performPrivateCommand(java.lang.String, android.os.Bundle).
OnRestoreInstanceState(IParcelable)
Hook allowing a view to re-apply a representation of its internal state that had previously been generated by View.OnSaveInstanceState.
OnSaveInstanceState() : IParcelable
Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state.
OnTextContextMenuItem(Int32) : Boolean
Called when a context menu option for the text view is selected.
RemoveTextChangedListener(ITextWatcher)
Removes the specified TextWatcher from the list of those whose methods are called whenever this TextView's text changes.
SetAllCaps(Boolean)
Sets the properties of this field to transform input to ALL CAPS display.
SetCompoundDrawables(Drawable, Drawable, Drawable, Drawable)
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text.
SetCompoundDrawablesRelative(Drawable, Drawable, Drawable, Drawable)
Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text.
SetCompoundDrawablesRelativeWithIntrinsicBounds(Drawable, Drawable, Drawable, Drawable)
Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text.
SetCompoundDrawablesRelativeWithIntrinsicBounds(Int32, Int32, Int32, Int32)
Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text.
SetCompoundDrawablesWithIntrinsicBounds(Drawable, Drawable, Drawable, Drawable)
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text.
SetCompoundDrawablesWithIntrinsicBounds(Int32, Int32, Int32, Int32)
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text.
SetCursorVisible(Boolean)
Set whether the cursor is visible.
SetEditableFactory(EditableFactory)
Sets the Factory used to create new Editables.
SetElegantTextHeight(Boolean)
Set the TextView's elegant height metrics flag.
SetEms(Int32)
Makes the TextView exactly this many ems wide
SetError(ICharSequence, Drawable)
Sets the right-hand compound drawable of the TextView to the specified icon and sets an error message that will be displayed in a popup when the TextView has focus.
SetError(String, Drawable)
SetExtractedText(ExtractedText)
Apply to this text view the given extracted text, as previously returned by TextView.ExtractText(ExtractedTextRequest,ExtractedText).
SetFilters(IInputFilter[])
Sets the list of input filters that will be used if the buffer is Editable.
SetHeight(Int32)
Makes the TextView exactly this many pixels tall.
SetHighlightColor(Color)
Sets the color used to display the selection highlight.
SetHint(Int32)
Sets the text to be displayed when the text of the TextView is empty, from a resource.
SetHintTextColor(ColorStateList)
Sets the color of the hint text.
SetHintTextColor(Color)
Sets the color of the hint text for all the states (disabled, focussed, selected...) of this TextView.
SetHorizontallyScrolling(Boolean)
Sets whether the text should be allowed to be wider than the View is.
SetImeActionLabel(ICharSequence, ImeAction)
Change the custom IME action associated with the text view, which will be reported to an IME with EditorInfo.ActionLabel and EditorInfo.ActionId when it has focus.
SetImeActionLabel(String, ImeAction)
SetIncludeFontPadding(Boolean)
Set whether the TextView includes extra top and bottom padding to make room for accents that go above the normal ascent and descent.
SetInputExtras(Int32)
Set the extra input data of the text, which is the EditorInfo.Extras Bundle that will be filled in when creating an input connection.
SetLines(Int32)
Makes the TextView exactly this many lines tall.
SetLineSpacing(Single, Single)
Sets line spacing for this TextView.
SetLinkTextColor(ColorStateList)
Sets the color of links in the text.
SetLinkTextColor(Color)
Sets the color of links in the text.
SetMarqueeRepeatLimit(Int32)
Sets how many times to repeat the marquee animation.
SetMaxEms(Int32)
Makes the TextView at most this many ems wide
SetMaxHeight(Int32)
Makes the TextView at most this many pixels tall.
SetMaxLines(Int32)
Makes the TextView at most this many lines tall.
SetMaxWidth(Int32)
Makes the TextView at most this many pixels wide
SetMinEms(Int32)
Makes the TextView at least this many ems wide
SetMinHeight(Int32)
Makes the TextView at least this many pixels tall.
SetMinLines(Int32)
Makes the TextView at least this many lines tall.
SetMinWidth(Int32)
Makes the TextView at least this many pixels wide
SetOnEditorActionListener(TextView+IOnEditorActionListener)
Set a special listener to be called when an action is performed on the text view.
override
SetPaddingRelative(Int32, Int32, Int32, Int32)
Sets the relative padding.
SetRawInputType(InputTypes)
Directly change the content type integer of the text view, without modifying any other state.
SetScroller(Scroller)
SetSelectAllOnFocus(Boolean)
Set the TextView so that when it takes focus, all the text is selected.
SetShadowLayer(Single, Single, Single, Color)
Gives the text a shadow of the specified blur radius and color, the specified distance from its drawn position.
SetSingleLine()
Sets the properties of this field (lines, horizontally scrolling, transformation method) to be for a single-line input.
SetSingleLine(Boolean)
If true, sets the properties of this field (number of lines, horizontally scrolling, transformation method) to be for a single-line input; if false, restores these to the default conditions.
SetSpannableFactory(SpannableFactory)
Sets the Factory used to create new Spannables.
SetText(Int32)
SetText(ICharSequence, TextView+BufferType)
Sets the text that this TextView is to display (see TextView.TextFormatted) and also sets whether it is stored in a styleable/spannable buffer and whether it is editable.
SetText(Int32, TextView+BufferType)
SetText(String, TextView+BufferType)
SetText(Char[], Int32, Int32)
Sets the TextView to display the specified slice of the specified char array.
SetTextAppearance(Context, Int32)
Sets the text color, size, style, hint color, and highlight color from the specified TextAppearance resource.
SetTextColor(ColorStateList)
Sets the text color.
SetTextColor(Color)
Sets the text color for all the states (normal, selected, focused) to be this color.
SetTextIsSelectable(Boolean)
Sets whether the content of this view is selectable by the user.
SetTextKeepState(ICharSequence)
Like TextView.TextFormatted, except that the cursor position (if any) is retained in the new text.
SetTextKeepState(String)
SetTextKeepState(ICharSequence, TextView+BufferType)
Like TextView.SetText(Java.Lang.ICharSequence, .BufferType), except that the cursor position (if any) is retained in the new text.
SetTextKeepState(String, TextView+BufferType)
SetTextSize(ComplexUnitType, Single)
Set the default text size to a given unit and value.
SetTypeface(Typeface, TypefaceStyle)
Sets the typeface and style in which the text should be displayed, and turns on the fake bold and italic bits in the Paint if the Typeface that you provided does not have all the bits in the style that you specified.
SetWidth(Int32)
Makes the TextView exactly this many pixels wide.

Protected Methods

OnSelectionChanged(Int32, Int32)
This method is called when the selection has changed, in case any subclasses would like to know.
OnTextChanged(ICharSequence, Int32, Int32, Int32)
This method is called when the text is changed, in case any subclasses would like to know.
OnTextChanged(String, Int32, Int32, Int32)
ResetResolvedDrawables()
ResetResolvedLayoutDirection()
ResolveDrawables()
ResolveTextDirection()
SetFrame(Int32, Int32, Int32, Int32) : Boolean
Assign a size and position to this view.

Public Events