public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
EditText
for a subclass that configures the text
view for editing.
XML attributes
See TextView Attributes
,
View Attributes
Modifier and Type | Class and Description |
---|---|
static class |
TextView.BufferType |
static interface |
TextView.OnEditorActionListener
Interface definition for a callback to be invoked when an action is
performed on the editor.
|
static class |
TextView.SavedState
User interface state that is stored by TextView for implementing
View.onSaveInstanceState() . |
View.AccessibilityDelegate, View.BaseSavedState, View.DragShadowBuilder, View.MeasureSpec, View.OnAttachStateChangeListener, View.OnClickListener, View.OnCreateContextMenuListener, View.OnDragListener, View.OnFocusChangeListener, View.OnGenericMotionListener, View.OnHoverListener, View.OnKeyListener, View.OnLayoutChangeListener, View.OnLongClickListener, View.OnSystemUiVisibilityChangeListener, View.OnTouchListener
ALPHA, DEBUG_LAYOUT_PROPERTY, DRAG_FLAG_GLOBAL, DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FIND_VIEWS_WITH_ACCESSIBILITY_NODE_PROVIDERS, FIND_VIEWS_WITH_CONTENT_DESCRIPTION, FIND_VIEWS_WITH_TEXT, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, IMPORTANT_FOR_ACCESSIBILITY_AUTO, IMPORTANT_FOR_ACCESSIBILITY_NO, IMPORTANT_FOR_ACCESSIBILITY_YES, INVISIBLE, KEEP_SCREEN_ON, LAYER_TYPE_HARDWARE, LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, mBottom, mCachingFailed, mContext, mCurrentAnimation, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, mInputEventConsistencyVerifier, mLayoutParams, mLeft, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mParent, mRight, mScrollX, mScrollY, mTag, mTop, mUserPaddingBottom, mUserPaddingLeft, mUserPaddingRight, NO_ID, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, PUBLIC_STATUS_BAR_VISIBILITY_MASK, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCREEN_STATE_OFF, SCREEN_STATE_ON, SCROLLBAR_POSITION_DEFAULT, SCROLLBAR_POSITION_LEFT, SCROLLBAR_POSITION_RIGHT, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, STATUS_BAR_DISABLE_BACK, STATUS_BAR_DISABLE_CLOCK, STATUS_BAR_DISABLE_EXPAND, STATUS_BAR_DISABLE_HOME, STATUS_BAR_DISABLE_NOTIFICATION_ALERTS, STATUS_BAR_DISABLE_NOTIFICATION_ICONS, STATUS_BAR_DISABLE_NOTIFICATION_TICKER, STATUS_BAR_DISABLE_RECENT, STATUS_BAR_DISABLE_SEARCH, STATUS_BAR_DISABLE_SYSTEM_INFO, STATUS_BAR_HIDDEN, STATUS_BAR_VISIBLE, SYSTEM_UI_CLEARABLE_FLAGS, SYSTEM_UI_FLAG_FULLSCREEN, SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LOW_PROFILE, SYSTEM_UI_FLAG_VISIBLE, SYSTEM_UI_LAYOUT_FLAGS, TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_GRAVITY, TEXT_ALIGNMENT_INHERIT, TEXT_ALIGNMENT_TEXT_END, TEXT_ALIGNMENT_TEXT_START, TEXT_ALIGNMENT_VIEW_END, TEXT_ALIGNMENT_VIEW_START, TEXT_DIRECTION_ANY_RTL, TEXT_DIRECTION_FIRST_STRONG, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TRANSLATION_X, TRANSLATION_Y, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y
Constructor and Description |
---|
TextView(Context context) |
TextView(Context context,
AttributeSet attrs) |
TextView(Context context,
AttributeSet attrs,
int defStyle) |
Modifier and Type | Method and Description |
---|---|
void |
addTextChangedListener(TextWatcher watcher)
Adds a TextWatcher to the list of those whose methods are called
whenever this TextView's text changes.
|
void |
append(CharSequence text)
Convenience method: Append the specified text to the TextView's
display buffer, upgrading it to BufferType.EDITABLE if it was
not already editable.
|
void |
append(CharSequence text,
int start,
int end)
Convenience method: Append the specified text slice to the TextView's
display buffer, upgrading it to BufferType.EDITABLE if it was
not already editable.
|
void |
beginBatchEdit() |
boolean |
bringPointIntoView(int offset)
Move the point, specified by the offset, into the view if it is needed.
|
void |
cancelLongPress()
Cancels a pending long press.
|
void |
clearComposingText()
Use
BaseInputConnection.removeComposingSpans() to remove any IME composing
state from this text view. |
protected int |
computeHorizontalScrollRange()
Compute the horizontal range that the horizontal scrollbar
represents.
|
void |
computeScroll()
Called by a parent to request that a child update its values for mScrollX
and mScrollY if necessary.
|
protected int |
computeVerticalScrollExtent()
Compute the vertical extent of the horizontal scrollbar's thumb
within the vertical range.
|
protected int |
computeVerticalScrollRange()
Compute the vertical range that the vertical scrollbar represents.
|
void |
debug(int depth)
Prints information about this view in the log output, with the tag
View.VIEW_LOG_TAG . |
protected void |
deleteText_internal(int start,
int end)
Deletes the range of text [start, end[.
|
boolean |
didTouchFocusSelect()
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.
|
void |
dispatchFinishTemporaryDetach() |
protected void |
drawableStateChanged()
This function is called whenever the state of the view changes in such
a way that it impacts the state of drawables being shown.
|
void |
endBatchEdit() |
boolean |
extractText(ExtractedTextRequest request,
ExtractedText outText)
If this TextView contains editable content, extract a portion of it
based on the information in request in to outText.
|
void |
findViewsWithText(ArrayList<View> outViews,
CharSequence searched,
int flags)
Finds the Views that contain given text.
|
int |
getAccessibilityCursorPosition() |
int |
getAutoLinkMask()
Gets the autolink mask of the text.
|
int |
getBaseline()
Return the offset of the widget's text baseline from the widget's top
boundary.
|
protected int |
getBottomPaddingOffset()
Amount by which to extend the bottom fading region.
|
int |
getCompoundDrawablePadding()
Returns the padding between the compound drawables and the text.
|
Drawable[] |
getCompoundDrawables()
Returns drawables for the left, top, right, and bottom borders.
|
Drawable[] |
getCompoundDrawablesRelative()
Returns drawables for the start, top, end, and bottom borders.
|
int |
getCompoundPaddingBottom()
Returns the bottom padding of the view, plus space for the bottom
Drawable if any.
|
int |
getCompoundPaddingEnd()
Returns the end padding of the view, plus space for the end
Drawable if any.
|
int |
getCompoundPaddingLeft()
Returns the left padding of the view, plus space for the left
Drawable if any.
|
int |
getCompoundPaddingRight()
Returns the right padding of the view, plus space for the right
Drawable if any.
|
int |
getCompoundPaddingStart()
Returns the start padding of the view, plus space for the start
Drawable if any.
|
int |
getCompoundPaddingTop()
Returns the top padding of the view, plus space for the top
Drawable if any.
|
int |
getCurrentHintTextColor()
Return the current color selected to paint the hint text.
|
int |
getCurrentTextColor()
Return the current color selected for normal text.
|
ActionMode.Callback |
getCustomSelectionActionModeCallback()
Retrieves the value set in
setCustomSelectionActionModeCallback(android.view.ActionMode.Callback) . |
protected boolean |
getDefaultEditable()
Subclasses override this to specify that they have a KeyListener
by default even if not specifically called for in the XML options.
|
protected MovementMethod |
getDefaultMovementMethod()
Subclasses override this to specify a default movement method.
|
Editable |
getEditableText()
Return the text the TextView is displaying as an Editable object.
|
TextUtils.TruncateAt |
getEllipsize()
Returns where, if anywhere, words that are longer than the view
is wide should be ellipsized.
|
CharSequence |
getError()
Returns the error message that was set to be displayed with
setError(java.lang.CharSequence) , or null if no error was set
or if it the error was cleared by the widget after user input. |
int |
getExtendedPaddingBottom()
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.
|
int |
getExtendedPaddingTop()
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.
|
protected int |
getFadeHeight(boolean offsetRequired) |
protected int |
getFadeTop(boolean offsetRequired) |
InputFilter[] |
getFilters()
Returns the current list of input filters.
|
void |
getFocusedRect(Rect r)
When a view has focus and the user navigates away from it, the next view is searched for
starting from the rectangle filled in by this method.
|
boolean |
getFreezesText()
Return whether this text view is including its entire text contents
in frozen icicles.
|
int |
getGravity()
Returns the horizontal and vertical alignment of this TextView.
|
int |
getHighlightColor() |
CharSequence |
getHint()
Returns the hint that is displayed when the text of the TextView
is empty.
|
ColorStateList |
getHintTextColors() |
boolean |
getHorizontallyScrolling()
Returns whether the text is allowed to be wider than the View is.
|
int |
getImeActionId()
Get the IME action ID previous set with
setImeActionLabel(java.lang.CharSequence, int) . |
CharSequence |
getImeActionLabel()
Get the IME action label previous set with
setImeActionLabel(java.lang.CharSequence, int) . |
int |
getImeOptions()
Get the type of the IME editor.
|
boolean |
getIncludeFontPadding()
Gets whether the TextView includes extra top and bottom padding to make
room for accents that go above the normal ascent and descent.
|
Bundle |
getInputExtras(boolean create)
Retrieve the input extras currently associated with the text view, which
can be viewed as well as modified.
|
int |
getInputType()
Get the type of the editable content.
|
CharSequence |
getIterableTextForAccessibility()
Gets the text reported for accessibility purposes.
|
AccessibilityIterators.TextSegmentIterator |
getIteratorForGranularity(int granularity) |
KeyListener |
getKeyListener() |
Layout |
getLayout() |
protected float |
getLeftFadingEdgeStrength()
Returns the strength, or intensity, of the left faded edge.
|
protected int |
getLeftPaddingOffset()
Amount by which to extend the left fading region.
|
int |
getLineBounds(int line,
Rect bounds)
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.
|
int |
getLineCount()
Return the number of lines of text, or 0 if the internal Layout has not
been built.
|
int |
getLineHeight() |
float |
getLineSpacingExtra()
Gets the line spacing extra space
|
float |
getLineSpacingMultiplier()
Gets the line spacing multiplier
|
boolean |
getLinksClickable()
Returns whether the movement method will automatically be set to
LinkMovementMethod if setAutoLinkMask(int) has been
set to nonzero and links are detected in setText(java.lang.CharSequence) . |
ColorStateList |
getLinkTextColors() |
int |
getMarqueeRepeatLimit()
Gets the number of times the marquee animation is repeated.
|
int |
getMaxEms() |
int |
getMaxHeight() |
int |
getMaxLines() |
int |
getMaxWidth() |
int |
getMinEms() |
int |
getMinHeight() |
int |
getMinLines() |
int |
getMinWidth() |
MovementMethod |
getMovementMethod() |
int |
getOffsetForPosition(float x,
float y)
Get the character offset closest to the specified absolute position.
|
TextPaint |
getPaint() |
int |
getPaintFlags() |
String |
getPrivateImeOptions()
Get the private type of the content.
|
protected float |
getRightFadingEdgeStrength()
Returns the strength, or intensity, of the right faded edge.
|
protected int |
getRightPaddingOffset()
Amount by which to extend the right fading region.
|
int |
getSelectionEnd()
Convenience for
Selection.getSelectionEnd(java.lang.CharSequence) . |
int |
getSelectionStart()
Convenience for
Selection.getSelectionStart(java.lang.CharSequence) . |
int |
getShadowColor() |
float |
getShadowDx() |
float |
getShadowDy() |
float |
getShadowRadius()
Gets the radius of the shadow layer.
|
boolean |
getShowSoftInputOnFocus()
Returns whether the soft input method will be made visible when this
TextView gets focused.
|
CharSequence |
getText()
Return the text the TextView is displaying.
|
static int |
getTextColor(Context context,
TypedArray attrs,
int def)
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.
|
ColorStateList |
getTextColors()
Gets the text colors for the different states (normal, selected, focused) of the TextView.
|
static ColorStateList |
getTextColors(Context context,
TypedArray attrs)
Returns the TextView_textColor attribute from the
Resources.StyledAttributes, if set, or the TextAppearance_textColor
from the TextView_textAppearance attribute, if TextView_textColor
was not set directly.
|
CharSequence |
getTextForAccessibility()
Gets the text reported for accessibility purposes.
|
Locale |
getTextLocale()
Get the default
Locale of the text in this TextView. |
float |
getTextScaleX() |
Locale |
getTextServicesLocale()
This is a temporary method.
|
float |
getTextSize() |
protected int |
getTopPaddingOffset()
Amount by which to extend the top fading region.
|
int |
getTotalPaddingBottom()
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.
|
int |
getTotalPaddingEnd()
Returns the total end padding of the view, including the end
Drawable if any.
|
int |
getTotalPaddingLeft()
Returns the total left padding of the view, including the left
Drawable if any.
|
int |
getTotalPaddingRight()
Returns the total right padding of the view, including the right
Drawable if any.
|
int |
getTotalPaddingStart()
Returns the total start padding of the view, including the start
Drawable if any.
|
int |
getTotalPaddingTop()
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.
|
TransformationMethod |
getTransformationMethod() |
Typeface |
getTypeface() |
URLSpan[] |
getUrls()
Returns the list of URLSpans attached to the text
(by
Linkify or otherwise) if any. |
WordIterator |
getWordIterator()
This method is used by the ArrowKeyMovementMethod to jump from one word to the other.
|
boolean |
hasOverlappingRendering()
Returns whether this View has content which overlaps.
|
boolean |
hasSelection()
Return true iff there is a selection inside this text view.
|
void |
hideErrorIfUnchanged() |
void |
invalidateDrawable(Drawable drawable)
Invalidates the specified Drawable.
|
boolean |
isCursorVisible() |
boolean |
isInputMethodTarget()
Returns whether this text view is a current input method target.
|
protected boolean |
isPaddingOffsetRequired()
If the View draws content inside its padding and enables fading edges,
it needs to support padding offsets.
|
boolean |
isSuggestionsEnabled()
Return whether or not suggestions are enabled on this TextView.
|
boolean |
isTextSelectable()
When a TextView is used to display a useful piece of information to the user (such as a
contact's address), it should be made selectable, so that the user can select and copy this
content.
|
void |
jumpDrawablesToCurrentState()
Call
Drawable.jumpToCurrentState()
on all Drawable objects associated with this view. |
int |
length()
Returns the length, in characters, of the text managed by this TextView
|
protected void |
makeNewLayout(int wantWidth,
int hintWidth,
BoringLayout.Metrics boring,
BoringLayout.Metrics hintBoring,
int ellipsisWidth,
boolean bringIntoView)
The width passed in is now the desired layout width,
not the full view width with padding.
|
boolean |
moveCursorToVisibleOffset()
Move the cursor, if needed, so that it is at an offset that is visible
to the user.
|
protected void |
onAttachedToWindow()
This is called when the view is attached to a window.
|
void |
onBeginBatchEdit()
Called by the framework in response to a request to begin a batch
of edit operations through a call to link
beginBatchEdit() . |
boolean |
onCheckIsTextEditor()
Check whether the called view is a text editor, in which case it
would make sense to automatically display a soft input window for
it.
|
void |
onCommitCompletion(CompletionInfo text)
Called by the framework in response to a text completion from
the current input method, provided by it calling
InputConnection.commitCompletion() . |
void |
onCommitCorrection(CorrectionInfo info)
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
InputConnection.commitCorrection(android.view.inputmethod.CorrectionInfo) InputConnection.commitCorrection()}. |
protected int[] |
onCreateDrawableState(int extraSpace)
Generate the new
Drawable state for
this view. |
InputConnection |
onCreateInputConnection(EditorInfo outAttrs)
Create a new InputConnection for an InputMethod to interact
with the view.
|
protected void |
onDetachedFromWindow()
This is called when the view is detached from a window.
|
boolean |
onDragEvent(DragEvent event)
Handles drag events sent by the system following a call to
startDrag() . |
protected void |
onDraw(Canvas canvas)
Implement this to do your drawing.
|
void |
onEditorAction(int actionCode)
Called when an attached input method calls
InputConnection.performEditorAction()
for this text view. |
void |
onEndBatchEdit()
Called by the framework in response to a request to end a batch
of edit operations through a call to link
endBatchEdit() . |
void |
onFinishTemporaryDetach()
Called after
View.onStartTemporaryDetach() when the container is done
changing the view. |
protected void |
onFocusChanged(boolean focused,
int direction,
Rect previouslyFocusedRect)
Called by the view system when the focus state of this view changes.
|
boolean |
onGenericMotionEvent(MotionEvent event)
Implement this method to handle generic motion events.
|
void |
onInitializeAccessibilityEvent(AccessibilityEvent event)
Initializes an
AccessibilityEvent with information about
this View which is the event source. |
void |
onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)
Initializes an
AccessibilityNodeInfo with information about this view. |
boolean |
onKeyDown(int keyCode,
KeyEvent event)
Default implementation of
KeyEvent.Callback.onKeyDown() : perform press of the view
when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER
is released, if the view is enabled and clickable. |
boolean |
onKeyMultiple(int keyCode,
int repeatCount,
KeyEvent event)
Default implementation of
KeyEvent.Callback.onKeyMultiple() : always returns false (doesn't handle
the event). |
boolean |
onKeyPreIme(int keyCode,
KeyEvent event)
Handle a key event before it is processed by any input method
associated with the view hierarchy.
|
boolean |
onKeyShortcut(int keyCode,
KeyEvent event)
Called on the focused view when a key shortcut event is not handled.
|
boolean |
onKeyUp(int keyCode,
KeyEvent event)
Default implementation of
KeyEvent.Callback.onKeyUp() : perform clicking of the view
when KeyEvent.KEYCODE_DPAD_CENTER or
KeyEvent.KEYCODE_ENTER is released. |
protected void |
onLayout(boolean changed,
int left,
int top,
int right,
int bottom)
Called from layout when this view should
assign a size and position to each of its children.
|
protected void |
onMeasure(int widthMeasureSpec,
int heightMeasureSpec)
Measure the view and its content to determine the measured width and the
measured height.
|
void |
onPopulateAccessibilityEvent(AccessibilityEvent event)
Called from
View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)
giving a chance to this View to populate the accessibility event with its
text content. |
boolean |
onPreDraw()
Callback method to be invoked when the view tree is about to be drawn.
|
boolean |
onPrivateIMECommand(String action,
Bundle data)
Called by the framework in response to a private command from the
current method, provided by it calling
InputConnection.performPrivateCommand() . |
void |
onResolveDrawables(int layoutDirection)
Called when layout direction has been resolved.
|
void |
onRestoreInstanceState(Parcelable state)
Hook allowing a view to re-apply a representation of its internal state that had previously
been generated by
View.onSaveInstanceState() . |
void |
onRtlPropertiesChanged(int layoutDirection)
Called when any RTL property (layout direction or text direction or text alignment) has
been changed.
|
Parcelable |
onSaveInstanceState()
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.
|
void |
onScreenStateChanged(int screenState)
This method is called whenever the state of the screen this view is
attached to changes.
|
protected void |
onScrollChanged(int horiz,
int vert,
int oldHoriz,
int oldVert)
This is called in response to an internal scroll in this view (i.e., the
view scrolled its own contents).
|
protected void |
onSelectionChanged(int selStart,
int selEnd)
This method is called when the selection has changed, in case any
subclasses would like to know.
|
void |
onStartTemporaryDetach()
This is called when a container is going to temporarily detach a child, with
ViewGroup.detachViewFromParent . |
protected void |
onTextChanged(CharSequence text,
int start,
int lengthBefore,
int lengthAfter)
This method is called when the text is changed, in case any subclasses
would like to know.
|
boolean |
onTextContextMenuItem(int id)
Called when a context menu option for the text view is selected.
|
boolean |
onTouchEvent(MotionEvent event)
Implement this method to handle touch screen motion events.
|
boolean |
onTrackballEvent(MotionEvent event)
Implement this method to handle trackball motion events.
|
protected void |
onVisibilityChanged(View changedView,
int visibility)
Called when the visibility of the view or an ancestor of the view is changed.
|
void |
onWindowFocusChanged(boolean hasWindowFocus)
Called when the window containing this view gains or loses focus.
|
boolean |
performLongClick()
Call this view's OnLongClickListener, if it is defined.
|
void |
removeTextChangedListener(TextWatcher watcher)
Removes the specified TextWatcher from the list of those whose
methods are called
whenever this TextView's text changes.
|
protected void |
replaceText_internal(int start,
int end,
CharSequence text)
Replaces the range of text [start, end[ by replacement text
|
void |
resetErrorChangedFlag()
Resets the mErrorWasChanged flag, so that future calls to
setError(CharSequence)
can be recorded. |
protected void |
resetResolvedDrawables() |
void |
sendAccessibilityEvent(int eventType)
Sends an accessibility event of the given type.
|
void |
setAccessibilityCursorPosition(int index) |
void |
setAllCaps(boolean allCaps)
Sets the properties of this field to transform input to ALL CAPS
display.
|
void |
setAutoLinkMask(int mask)
Sets the autolink mask of the text.
|
void |
setCompoundDrawablePadding(int pad)
Sets the size of the padding between the compound drawables and
the text.
|
void |
setCompoundDrawables(Drawable left,
Drawable top,
Drawable right,
Drawable bottom)
Sets the Drawables (if any) to appear to the left of, above,
to the right of, and below the text.
|
void |
setCompoundDrawablesRelative(Drawable start,
Drawable top,
Drawable end,
Drawable bottom)
Sets the Drawables (if any) to appear to the start of, above,
to the end of, and below the text.
|
void |
setCompoundDrawablesRelativeWithIntrinsicBounds(Drawable start,
Drawable top,
Drawable end,
Drawable bottom)
Sets the Drawables (if any) to appear to the start of, above,
to the end of, and below the text.
|
void |
setCompoundDrawablesRelativeWithIntrinsicBounds(int start,
int top,
int end,
int bottom)
Sets the Drawables (if any) to appear to the start of, above,
to the end of, and below the text.
|
void |
setCompoundDrawablesWithIntrinsicBounds(Drawable left,
Drawable top,
Drawable right,
Drawable bottom)
Sets the Drawables (if any) to appear to the left of, above,
to the right of, and below the text.
|
void |
setCompoundDrawablesWithIntrinsicBounds(int left,
int top,
int right,
int bottom)
Sets the Drawables (if any) to appear to the left of, above,
to the right of, and below the text.
|
protected void |
setCursorPosition_internal(int start,
int end)
Moves the cursor to the specified offset position in text
|
void |
setCursorVisible(boolean visible)
Set whether the cursor is visible.
|
void |
setCustomSelectionActionModeCallback(ActionMode.Callback actionModeCallback)
If provided, this ActionMode.Callback will be used to create the ActionMode when text
selection is initiated in this View.
|
void |
setEditableFactory(Editable.Factory factory)
Sets the Factory used to create new Editables.
|
void |
setEllipsize(TextUtils.TruncateAt where)
Causes words in the text that are longer than the view is wide
to be ellipsized instead of broken in the middle.
|
void |
setEms(int ems)
Makes the TextView exactly this many ems wide
|
void |
setEnabled(boolean enabled)
Set the enabled state of this view.
|
void |
setError(CharSequence error)
Sets the right-hand compound drawable of the TextView to the "error"
icon and sets an error message that will be displayed in a popup when
the TextView has focus.
|
void |
setError(CharSequence error,
Drawable icon)
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.
|
void |
setExtractedText(ExtractedText text)
Apply to this text view the given extracted text, as previously
returned by
extractText(ExtractedTextRequest, ExtractedText) . |
void |
setExtracting(ExtractedTextRequest req) |
void |
setFilters(InputFilter[] filters)
Sets the list of input filters that will be used if the buffer is
Editable.
|
protected boolean |
setFrame(int l,
int t,
int r,
int b)
Assign a size and position to this view.
|
void |
setFreezesText(boolean freezesText)
Control whether this text view saves its entire text contents when
freezing to an icicle, in addition to dynamic state such as cursor
position.
|
void |
setGravity(int gravity)
Sets the horizontal alignment of the text and the
vertical gravity that will be used when there is extra space
in the TextView beyond what is required for the text itself.
|
void |
setHeight(int pixels)
Makes the TextView exactly this many pixels tall.
|
void |
setHighlightColor(int color)
Sets the color used to display the selection highlight.
|
void |
setHint(CharSequence hint)
Sets the text to be displayed when the text of the TextView is empty.
|
void |
setHint(int resid)
Sets the text to be displayed when the text of the TextView is empty,
from a resource.
|
void |
setHintTextColor(ColorStateList colors)
Sets the color of the hint text.
|
void |
setHintTextColor(int color)
Sets the color of the hint text for all the states (disabled, focussed, selected...) of this
TextView.
|
void |
setHorizontallyScrolling(boolean whether)
Sets whether the text should be allowed to be wider than the
View is.
|
void |
setImeActionLabel(CharSequence label,
int actionId)
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. |
void |
setImeOptions(int imeOptions)
Change the editor type integer associated with the text view, which
will be reported to an IME with
EditorInfo.imeOptions when it
has focus. |
void |
setIncludeFontPadding(boolean includepad)
Set whether the TextView includes extra top and bottom padding to make
room for accents that go above the normal ascent and descent.
|
void |
setInputExtras(int xmlResId)
Set the extra input data of the text, which is the
TextBoxAttribute.extras
Bundle that will be filled in when creating an input connection. |
void |
setInputType(int type)
Set the type of the content with a constant as defined for
EditorInfo.inputType . |
void |
setKeyListener(KeyListener input)
Sets the key listener to be used with this TextView.
|
void |
setLines(int lines)
Makes the TextView exactly this many lines tall.
|
void |
setLineSpacing(float add,
float mult)
Sets line spacing for this TextView.
|
void |
setLinksClickable(boolean whether)
Sets whether the movement method will automatically be set to
LinkMovementMethod if setAutoLinkMask(int) has been
set to nonzero and links are detected in setText(java.lang.CharSequence) . |
void |
setLinkTextColor(ColorStateList colors)
Sets the color of links in the text.
|
void |
setLinkTextColor(int color)
Sets the color of links in the text.
|
void |
setMarqueeRepeatLimit(int marqueeLimit)
Sets how many times to repeat the marquee animation.
|
void |
setMaxEms(int maxems)
Makes the TextView at most this many ems wide
|
void |
setMaxHeight(int maxHeight)
Makes the TextView at most this many pixels tall.
|
void |
setMaxLines(int maxlines)
Makes the TextView at most this many lines tall.
|
void |
setMaxWidth(int maxpixels)
Makes the TextView at most this many pixels wide
|
void |
setMinEms(int minems)
Makes the TextView at least this many ems wide
|
void |
setMinHeight(int minHeight)
Makes the TextView at least this many pixels tall.
|
void |
setMinLines(int minlines)
Makes the TextView at least this many lines tall.
|
void |
setMinWidth(int minpixels)
Makes the TextView at least this many pixels wide
|
void |
setMovementMethod(MovementMethod movement)
Sets the movement method (arrow key handler) to be used for
this TextView.
|
void |
setOnEditorActionListener(TextView.OnEditorActionListener l)
Set a special listener to be called when an action is performed
on the text view.
|
void |
setPadding(int left,
int top,
int right,
int bottom)
Sets the padding.
|
void |
setPaddingRelative(int start,
int top,
int end,
int bottom)
Sets the relative padding.
|
void |
setPaintFlags(int flags)
Sets flags on the Paint being used to display the text and
reflows the text if they are different from the old flags.
|
void |
setPrivateImeOptions(String type)
Set the private content type of the text, which is the
EditorInfo.privateImeOptions
field that will be filled in when creating an input connection. |
void |
setRawInputType(int type)
Directly change the content type integer of the text view, without
modifying any other state.
|
void |
setScroller(Scroller s) |
void |
setSelectAllOnFocus(boolean selectAllOnFocus)
Set the TextView so that when it takes focus, all the text is
selected.
|
void |
setSelected(boolean selected)
Changes the selection state of this view.
|
void |
setShadowLayer(float radius,
float dx,
float dy,
int color)
Gives the text a shadow of the specified radius and color, the specified
distance from its normal position.
|
void |
setShowSoftInputOnFocus(boolean show)
Sets whether the soft input method will be made visible when this
TextView gets focused.
|
void |
setSingleLine()
Sets the properties of this field (lines, horizontally scrolling,
transformation method) to be for a single-line input.
|
void |
setSingleLine(boolean singleLine)
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.
|
protected void |
setSpan_internal(Object span,
int start,
int end,
int flags)
Sets a span on the specified range of text
|
void |
setSpannableFactory(Spannable.Factory factory)
Sets the Factory used to create new Spannables.
|
void |
setText(char[] text,
int start,
int len)
Sets the TextView to display the specified slice of the specified
char array.
|
void |
setText(CharSequence text)
Sets the string value of the TextView.
|
void |
setText(CharSequence text,
TextView.BufferType type)
Sets the text that this TextView is to display (see
setText(CharSequence) ) and also sets whether it is stored
in a styleable/spannable buffer and whether it is editable. |
void |
setText(int resid) |
void |
setText(int resid,
TextView.BufferType type) |
void |
setTextAppearance(Context context,
int resid)
Sets the text color, size, style, hint color, and highlight color
from the specified TextAppearance resource.
|
void |
setTextColor(ColorStateList colors)
Sets the text color.
|
void |
setTextColor(int color)
Sets the text color for all the states (normal, selected,
focused) to be this color.
|
void |
setTextIsSelectable(boolean selectable)
Sets whether or not (default) the content of this view is selectable by the user.
|
void |
setTextKeepState(CharSequence text)
Like
setText(CharSequence) ,
except that the cursor position (if any) is retained in the new text. |
void |
setTextKeepState(CharSequence text,
TextView.BufferType type)
Like
setText(CharSequence, android.widget.TextView.BufferType) ,
except that the cursor position (if any) is retained in the new text. |
void |
setTextLocale(Locale locale)
Set the default
Locale of the text in this TextView to the given value. |
void |
setTextScaleX(float size)
Sets the extent by which text should be stretched horizontally.
|
void |
setTextSize(float size)
Set the default text size to the given value, interpreted as "scaled
pixel" units.
|
void |
setTextSize(int unit,
float size)
Set the default text size to a given unit and value.
|
void |
setTransformationMethod(TransformationMethod method)
Sets the transformation that is applied to the text that this
TextView is displaying.
|
void |
setTypeface(Typeface tf)
Sets the typeface and style in which the text should be displayed.
|
void |
setTypeface(Typeface tf,
int style)
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.
|
void |
setWidth(int pixels)
Makes the TextView exactly this many pixels wide.
|
protected void |
stopSelectionActionMode() |
protected boolean |
verifyDrawable(Drawable who)
If your view subclass is displaying its own Drawable objects, it should
override this function and return true for any Drawable it is
displaying.
|
protected void |
viewClicked(InputMethodManager imm) |
addChildrenForAccessibility, addFocusables, addFocusables, addOnAttachStateChangeListener, addOnLayoutChangeListener, addTouchables, animate, announceForAccessibility, applyDrawableToTransparentRegion, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, canHaveDisplayList, canResolveLayoutDirection, canScrollHorizontally, canScrollVertically, checkInputConnectionProxy, clearAccessibilityFocus, clearAnimation, clearFocus, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeOpaqueFlags, computeVerticalScrollOffset, createAccessibilityNodeInfo, createContextMenu, debug, debugIndent, destroyDrawingCache, destroyHardwareResources, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDraw, dispatchGenericFocusedEvent, dispatchGenericMotionEvent, dispatchGenericPointerEvent, dispatchGetDisplayList, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPointerEvent, dispatchPopulateAccessibilityEvent, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, draw, findFocus, findViewById, findViewByPredicate, findViewByPredicateInsideOut, findViewByPredicateTraversal, findViewTraversal, findViewWithTag, findViewWithTagTraversal, fitsSystemWindows, fitSystemWindows, focusSearch, forceLayout, gatherTransparentRegion, generateViewId, getAccessibilityDelegate, getAccessibilityNodeProvider, getAccessibilityViewId, getAccessibilityWindowId, getAlpha, getAnimation, getApplicationWindowToken, getBackground, getBottom, getBottomFadingEdgeStrength, getCameraDistance, getContentDescription, getContext, getContextMenuInfo, getDefaultSize, getDisplay, getDisplayList, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusables, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHardwareRenderer, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getHorizontalScrollFactor, getId, getImportantForAccessibility, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOpticalInsets, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getRawLayoutDirection, getRawTextAlignment, getRawTextDirection, getResources, getRight, getRootView, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getSystemUiVisibility, getTag, getTag, getTextAlignment, getTextDirection, getTop, getTopFadingEdgeStrength, getTouchables, getTouchDelegate, getTranslationX, getTranslationY, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarWidth, getVerticalScrollFactor, getViewRootImpl, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, hackTurnOffWindowResizeAnim, hasFocus, hasFocusable, hasHoveredChild, hasOnClickListeners, hasOpaqueScrollbars, hasTransientState, hasWindowFocus, includeForAccessibility, inflate, initializeFadingEdge, initializeScrollbars, internalSetPadding, invalidate, invalidate, invalidate, invalidateParentCaches, invalidateParentIfNeeded, isActionableForAccessibility, isActivated, isClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isInEditMode, isInScrollingContainer, isInTouchMode, isLayoutDirectionInherited, isLayoutRequested, isLayoutRtl, isLongClickable, isOpaque, isPaddingRelative, isPressed, isRootNamespace, isSaveEnabled, isSaveFromParentEnabled, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShown, isSoundEffectsEnabled, isTextAlignmentInherited, isTextDirectionInherited, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVerticalScrollBarHidden, isVisibleToUser, isVisibleToUser, layout, makeOptionalFitsSystemWindows, measure, mergeDrawableStates, notifyAccessibilityStateChanged, offsetLeftAndRight, offsetTopAndBottom, onAnimationEnd, onAnimationStart, onCloseSystemDialogs, onConfigurationChanged, onCreateContextMenu, onDisplayHint, onDrawHorizontalScrollBar, onDrawScrollBars, onDrawVerticalScrollBar, onFilterTouchEventForSecurity, onFinishInflate, onFocusLost, onHoverChanged, onHoverEvent, onKeyLongPress, onOverScrolled, onSetAlpha, onSizeChanged, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, outputDirtyFlags, overScrollBy, performAccessibilityAction, performButtonActionOnTouchDown, performClick, performHapticFeedback, performHapticFeedback, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, recomputePadding, refreshDrawableState, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestAccessibilityFocus, requestFitSystemWindows, requestFocus, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, resetAccessibilityStateChanged, resetPaddingToInitialValues, resetResolvedLayoutDirection, resetResolvedPadding, resetResolvedTextAlignment, resetResolvedTextDirection, resetRtlProperties, resolveDrawables, resolveLayoutDirection, resolveLayoutParams, resolvePadding, resolveRtlPropertiesIfNeeded, resolveSize, resolveSizeAndState, resolveTextAlignment, resolveTextDirection, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEventUnchecked, setAccessibilityDelegate, setActivated, setAlpha, setAnimation, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBottom, setCameraDistance, setClickable, setContentDescription, setDisabledSystemUiVisibility, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusableInTouchMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHovered, setId, setImportantForAccessibility, setIsRootNamespace, setKeepScreenOn, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutInsets, setLayoutParams, setLeft, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOverScrollMode, setPivotX, setPivotY, setPressed, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollX, setScrollY, setSoundEffectsEnabled, setSystemUiVisibility, setTag, setTag, setTagInternal, setTextAlignment, setTextDirection, setTop, setTouchDelegate, setTranslationX, setTranslationY, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, showContextMenu, showContextMenu, startActionMode, startAnimation, startDrag, toString, unscheduleDrawable, unscheduleDrawable, willNotCacheDrawing, willNotDraw
public TextView(Context context)
public TextView(Context context, AttributeSet attrs)
public TextView(Context context, AttributeSet attrs, int defStyle)
public void setEnabled(boolean enabled)
View
setEnabled
in class View
enabled
- True if this view is enabled, false otherwise.public void setTypeface(Typeface tf, int style)
protected boolean getDefaultEditable()
protected MovementMethod getDefaultMovementMethod()
public CharSequence getText()
public int length()
public Editable getEditableText()
getText()
public int getLineHeight()
public final Layout getLayout()
public final KeyListener getKeyListener()
public void setKeyListener(KeyListener input)
KeyListener.getContentType()
for important details. Calling this method will replace the current
content type of the text view with the content type returned by the
key listener.
Be warned that if you want a TextView with a key listener or movement
method not to be focusable, or if you want a TextView without a
key listener or movement method to be focusable, you must call
View.setFocusable(boolean)
again after calling this to get the focusability
back the way you want it.
public final MovementMethod getMovementMethod()
public final void setMovementMethod(MovementMethod movement)
Be warned that if you want a TextView with a key listener or movement
method not to be focusable, or if you want a TextView without a
key listener or movement method to be focusable, you must call
View.setFocusable(boolean)
again after calling this to get the focusability
back the way you want it.
public final TransformationMethod getTransformationMethod()
public final void setTransformationMethod(TransformationMethod method)
public int getCompoundPaddingTop()
public int getCompoundPaddingBottom()
public int getCompoundPaddingLeft()
public int getCompoundPaddingRight()
public int getCompoundPaddingStart()
public int getCompoundPaddingEnd()
public int getExtendedPaddingTop()
public int getExtendedPaddingBottom()
public int getTotalPaddingLeft()
public int getTotalPaddingRight()
public int getTotalPaddingStart()
public int getTotalPaddingEnd()
public int getTotalPaddingTop()
public int getTotalPaddingBottom()
public void setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom)
Drawable.setBounds(int, int, int, int)
called.public void setCompoundDrawablesWithIntrinsicBounds(int left, int top, int right, int bottom)
left
- Resource identifier of the left Drawable.top
- Resource identifier of the top Drawable.right
- Resource identifier of the right Drawable.bottom
- Resource identifier of the bottom Drawable.public void setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom)
public void setCompoundDrawablesRelative(Drawable start, Drawable top, Drawable end, Drawable bottom)
Drawable.setBounds(int, int, int, int)
called.public void setCompoundDrawablesRelativeWithIntrinsicBounds(int start, int top, int end, int bottom)
start
- Resource identifier of the start Drawable.top
- Resource identifier of the top Drawable.end
- Resource identifier of the end Drawable.bottom
- Resource identifier of the bottom Drawable.public void setCompoundDrawablesRelativeWithIntrinsicBounds(Drawable start, Drawable top, Drawable end, Drawable bottom)
public Drawable[] getCompoundDrawables()
public Drawable[] getCompoundDrawablesRelative()
public void setCompoundDrawablePadding(int pad)
public int getCompoundDrawablePadding()
public void setPadding(int left, int top, int right, int bottom)
View
View.getPaddingLeft()
, View.getPaddingTop()
,
View.getPaddingRight()
and View.getPaddingBottom()
may be different
from the values set in this call.setPadding
in class View
left
- the left padding in pixelstop
- the top padding in pixelsright
- the right padding in pixelsbottom
- the bottom padding in pixelspublic void setPaddingRelative(int start, int top, int end, int bottom)
View
View.getPaddingStart()
, View.getPaddingTop()
,
View.getPaddingEnd()
and View.getPaddingBottom()
may be different
from the values set in this call.setPaddingRelative
in class View
start
- the start padding in pixelstop
- the top padding in pixelsend
- the end padding in pixelsbottom
- the bottom padding in pixelspublic final int getAutoLinkMask()
Linkify.ALL
and peers for
possible values.public void setTextAppearance(Context context, int resid)
public Locale getTextLocale()
Locale
of the text in this TextView.Locale
of the text in this TextView.public void setTextLocale(Locale locale)
Locale
of the text in this TextView to the given value. This value
is used to choose appropriate typefaces for ambiguous characters. Typically used for CJK
locales to disambiguate Hanzi/Kanji/Hanja characters.locale
- the Locale
for drawing text, must not be null.Paint.setTextLocale(java.util.Locale)
public float getTextSize()
public void setTextSize(float size)
size
- The scaled pixel size.public void setTextSize(int unit, float size)
TypedValue
for the possible dimension units.unit
- The desired dimension unit.size
- The desired size in the given units.public float getTextScaleX()
public void setTextScaleX(float size)
public void setTypeface(Typeface tf)
setTypeface(Typeface, int)
to get the appearance
that you actually want.getTypeface()
public Typeface getTypeface()
setTypeface(Typeface)
public void setTextColor(int color)
setTextColor(ColorStateList)
,
getTextColors()
public void setTextColor(ColorStateList colors)
public final ColorStateList getTextColors()
public final int getCurrentTextColor()
Return the current color selected for normal text.
public void setHighlightColor(int color)
public int getHighlightColor()
setHighlightColor(int)
public final void setShowSoftInputOnFocus(boolean show)
public final boolean getShowSoftInputOnFocus()
public void setShadowLayer(float radius, float dx, float dy, int color)
public float getShadowRadius()
setShadowLayer(float, float, float, int)
public float getShadowDx()
setShadowLayer(float, float, float, int)
public float getShadowDy()
setShadowLayer(float, float, float, int)
public int getShadowColor()
setShadowLayer(float, float, float, int)
public TextPaint getPaint()
public final void setAutoLinkMask(int mask)
Linkify.ALL
and peers for
possible values.public final void setLinksClickable(boolean whether)
LinkMovementMethod
if setAutoLinkMask(int)
has been
set to nonzero and links are detected in setText(java.lang.CharSequence)
.
The default is true.public final boolean getLinksClickable()
LinkMovementMethod
if setAutoLinkMask(int)
has been
set to nonzero and links are detected in setText(java.lang.CharSequence)
.
The default is true.public URLSpan[] getUrls()
Linkify
or otherwise) if any. You can call
URLSpan.getURL()
on them to find where they link to
or use Spanned.getSpanStart(java.lang.Object)
and Spanned.getSpanEnd(java.lang.Object)
to find the region of the text they are attached to.public final void setHintTextColor(int color)
public final void setHintTextColor(ColorStateList colors)
public final ColorStateList getHintTextColors()
setHintTextColor(ColorStateList)
,
setHintTextColor(int)
,
setTextColor(ColorStateList)
,
setLinkTextColor(ColorStateList)
public final int getCurrentHintTextColor()
Return the current color selected to paint the hint text.
public final void setLinkTextColor(int color)
public final void setLinkTextColor(ColorStateList colors)
public final ColorStateList getLinkTextColors()
setLinkTextColor(ColorStateList)
,
setLinkTextColor(int)
public void setGravity(int gravity)
Gravity
public int getGravity()
Gravity
public int getPaintFlags()
Paint.getFlags()
public void setPaintFlags(int flags)
Paint.setFlags(int)
public void setHorizontallyScrolling(boolean whether)
public boolean getHorizontallyScrolling()
public void setMinLines(int minlines)
getMinLines()
public int getMinLines()
or #setHeight(int)
.setMinLines(int)
public void setMinHeight(int minHeight)
public int getMinHeight()
or #setLines(int)
.setMinHeight(int)
public void setMaxLines(int maxlines)
public int getMaxLines()
or #setHeight(int)
.setMaxLines(int)
public void setMaxHeight(int maxHeight)
setMaxLines(int)
method.
Setting this value overrides any other (maximum) number of lines setting.public int getMaxHeight()
or #setLines(int)
.setMaxHeight(int)
public void setLines(int lines)
public void setHeight(int pixels)
public void setMinEms(int minems)
public int getMinEms()
setMinWidth(int)
or setWidth(int)
).setMinEms(int)
,
setEms(int)
public void setMinWidth(int minpixels)
public int getMinWidth()
setMinEms(int)
or setEms(int)
).setMinWidth(int)
,
setWidth(int)
public void setMaxEms(int maxems)
public int getMaxEms()
setMaxWidth(int)
or setWidth(int)
).setMaxEms(int)
,
setEms(int)
public void setMaxWidth(int maxpixels)
public int getMaxWidth()
setMaxEms(int)
or setEms(int)
).setMaxWidth(int)
,
setWidth(int)
public void setEms(int ems)
setMaxEms(int)
,
setMinEms(int)
,
getMinEms()
,
getMaxEms()
public void setWidth(int pixels)
setMaxWidth(int)
,
setMinWidth(int)
,
getMinWidth()
,
getMaxWidth()
public void setLineSpacing(float add, float mult)
mult
and have add
added to it.public float getLineSpacingMultiplier()
setLineSpacing(float, float)
,
getLineSpacingExtra()
public float getLineSpacingExtra()
setLineSpacing(float, float)
,
getLineSpacingMultiplier()
public final void append(CharSequence text)
public void append(CharSequence text, int start, int end)
protected void drawableStateChanged()
View
Be sure to call through to the superclass when overriding this function.
drawableStateChanged
in class View
Drawable.setState(int[])
public Parcelable onSaveInstanceState()
View
Some examples of things you may store here: the current cursor position in a text view (but usually not the text itself since that is stored in a content provider or other persistent storage), the currently selected item in a list view.
onSaveInstanceState
in class View
View.onRestoreInstanceState(android.os.Parcelable)
,
View.saveHierarchyState(android.util.SparseArray)
,
View.dispatchSaveInstanceState(android.util.SparseArray)
,
View.setSaveEnabled(boolean)
public void onRestoreInstanceState(Parcelable state)
View
View.onSaveInstanceState()
. This function will never be called with a
null state.onRestoreInstanceState
in class View
state
- The frozen state that had previously been returned by
View.onSaveInstanceState()
.View.onSaveInstanceState()
,
View.restoreHierarchyState(android.util.SparseArray)
,
View.dispatchRestoreInstanceState(android.util.SparseArray)
public void setFreezesText(boolean freezesText)
freezesText
- Controls whether a frozen icicle should include the
entire text data: true to include it, false to not.public boolean getFreezesText()
setFreezesText(boolean)
public final void setEditableFactory(Editable.Factory factory)
public final void setSpannableFactory(Spannable.Factory factory)
public final void setText(CharSequence text)
SpannableString
, or see the
Available Resource Types documentation for an example of setting
formatted text in the XML resource file.public final void setTextKeepState(CharSequence text)
setText(CharSequence)
,
except that the cursor position (if any) is retained in the new text.text
- The new text to place in the text view.setText(CharSequence)
public void setText(CharSequence text, TextView.BufferType type)
setText(CharSequence)
) and also sets whether it is stored
in a styleable/spannable buffer and whether it is editable.public final void setText(char[] text, int start, int len)
public final void setTextKeepState(CharSequence text, TextView.BufferType type)
setText(CharSequence, android.widget.TextView.BufferType)
,
except that the cursor position (if any) is retained in the new text.public final void setText(int resid)
public final void setText(int resid, TextView.BufferType type)
public final void setHint(CharSequence hint)
public final void setHint(int resid)
public CharSequence getHint()
public void setInputType(int type)
EditorInfo.inputType
. This
will take care of changing the key listener, by calling setKeyListener(KeyListener)
,
to match the given content type. If the given content type is InputType.TYPE_NULL
then a soft keyboard will not be displayed for this text view.
Note that the maximum number of displayed lines (see setMaxLines(int)
) will be
modified if you change the InputType.TYPE_TEXT_FLAG_MULTI_LINE
flag of the input
type.getInputType()
,
setRawInputType(int)
,
InputType
public void setRawInputType(int type)
setInputType(int)
,
InputType
public int getInputType()
setInputType(int)
,
InputType
public void setImeOptions(int imeOptions)
EditorInfo.imeOptions
when it
has focus.getImeOptions()
,
EditorInfo
public int getImeOptions()
setImeOptions(int)
,
EditorInfo
public void setImeActionLabel(CharSequence label, int actionId)
EditorInfo.actionLabel
and EditorInfo.actionId
when it has focus.getImeActionLabel()
,
getImeActionId()
,
EditorInfo
public CharSequence getImeActionLabel()
setImeActionLabel(java.lang.CharSequence, int)
.public int getImeActionId()
setImeActionLabel(java.lang.CharSequence, int)
.public void setOnEditorActionListener(TextView.OnEditorActionListener l)
public void onEditorAction(int actionCode)
InputConnection.performEditorAction()
for this text view. The default implementation will call your action
listener supplied to setOnEditorActionListener(android.widget.TextView.OnEditorActionListener)
, or perform
a standard operation for EditorInfo.IME_ACTION_NEXT
, EditorInfo.IME_ACTION_PREVIOUS
, or EditorInfo.IME_ACTION_DONE
.
For backwards compatibility, if no IME options have been set and the text view would not normally advance focus on enter, then the NEXT and DONE actions received here will be turned into an enter key down/up pair to go through the normal key handling.
actionCode
- The code of the action being performed.setOnEditorActionListener(android.widget.TextView.OnEditorActionListener)
public void setPrivateImeOptions(String type)
EditorInfo.privateImeOptions
field that will be filled in when creating an input connection.public String getPrivateImeOptions()
public void setInputExtras(int xmlResId) throws XmlPullParserException, IOException
TextBoxAttribute.extras
Bundle that will be filled in when creating an input connection. The
given integer is the resource ID of an XML resource holding an
<input-extras>
XML tree.XmlPullParserException
IOException
getInputExtras(boolean)
,
EditorInfo.extras
public Bundle getInputExtras(boolean create)
create
- If true, the extras will be created if they don't already
exist. Otherwise, null will be returned if none have been created.setInputExtras(int)
,
EditorInfo.extras
public CharSequence getError()
setError(java.lang.CharSequence)
, or null
if no error was set
or if it the error was cleared by the widget after user input.public void setError(CharSequence error)
error
is null
, the error message and icon
will be cleared.public void setError(CharSequence error, Drawable icon)
Drawable.setBounds(int, int, int, int)
set on it.
If the error
is null
, the error message will
be cleared (and you should provide a null
icon as well).protected boolean setFrame(int l, int t, int r, int b)
View
public void setFilters(InputFilter[] filters)
public InputFilter[] getFilters()
public boolean onPreDraw()
onPreDraw
in interface ViewTreeObserver.OnPreDrawListener
View.onMeasure(int, int)
,
View.onLayout(boolean, int, int, int, int)
,
View.onDraw(android.graphics.Canvas)
protected void onAttachedToWindow()
View
View.onDraw(android.graphics.Canvas)
,
however it may be called any time before the first onDraw -- including
before or after View.onMeasure(int, int)
.onAttachedToWindow
in class View
View.onDetachedFromWindow()
protected void onDetachedFromWindow()
View
onDetachedFromWindow
in class View
View.onAttachedToWindow()
public void onScreenStateChanged(int screenState)
View
onScreenStateChanged
in class View
screenState
- The new state of the screen. Can be either
View.SCREEN_STATE_ON
or View.SCREEN_STATE_OFF
protected boolean isPaddingOffsetRequired()
View
isPaddingOffsetRequired
in class View
View.getLeftPaddingOffset()
,
View.getRightPaddingOffset()
,
View.getTopPaddingOffset()
,
View.getBottomPaddingOffset()
protected int getLeftPaddingOffset()
View
View.isPaddingOffsetRequired()
returns true.getLeftPaddingOffset
in class View
View.isPaddingOffsetRequired()
protected int getTopPaddingOffset()
View
View.isPaddingOffsetRequired()
returns true.getTopPaddingOffset
in class View
View.isPaddingOffsetRequired()
protected int getBottomPaddingOffset()
View
View.isPaddingOffsetRequired()
returns true.getBottomPaddingOffset
in class View
View.isPaddingOffsetRequired()
protected int getRightPaddingOffset()
View
View.isPaddingOffsetRequired()
returns true.getRightPaddingOffset
in class View
View.isPaddingOffsetRequired()
protected boolean verifyDrawable(Drawable who)
View
Be sure to call through to the super class when overriding this function.
verifyDrawable
in class View
who
- The Drawable to verify. Return true if it is one you are
displaying, else return the result of calling through to the
super class.View.unscheduleDrawable(android.graphics.drawable.Drawable)
,
View.drawableStateChanged()
public void jumpDrawablesToCurrentState()
View
Drawable.jumpToCurrentState()
on all Drawable objects associated with this view.jumpDrawablesToCurrentState
in class View
public void invalidateDrawable(Drawable drawable)
View
invalidateDrawable
in interface Drawable.Callback
invalidateDrawable
in class View
drawable
- the drawable to invalidatepublic boolean hasOverlappingRendering()
View
hasOverlappingRendering
in class View
public boolean isTextSelectable()
setTextIsSelectable(boolean)
or the
android.R.styleable#TextView_textIsSelectable
XML attribute to make this TextView
selectable (text is not selectable by default).
Note that this method simply returns the state of this flag. Although this flag has to be set
in order to select text in non-editable TextView, the content of an EditText
can
always be selected, independently of the value of this flag.public void setTextIsSelectable(boolean selectable)
View.setFocusable(boolean)
,
View.setFocusableInTouchMode(boolean)
View.setClickable(boolean)
and
View.setLongClickable(boolean)
states and you may want to restore these if they were
customized.
See isTextSelectable()
for details.selectable
- Whether or not the content of this TextView should be selectable.protected int[] onCreateDrawableState(int extraSpace)
View
Drawable
state for
this view. This is called by the view
system when the cached Drawable state is determined to be invalid. To
retrieve the current state, you should use View.getDrawableState()
.onCreateDrawableState
in class View
extraSpace
- if non-zero, this is the number of extra entries you
would like in the returned array in which you can place your own
states.Drawable
state of
the view.View.mergeDrawableStates(int[], int[])
protected void onDraw(Canvas canvas)
View
public void getFocusedRect(Rect r)
View
View.getDrawingRect(android.graphics.Rect)
)
of the view. However, if your view maintains some idea of internal selection,
such as a cursor, or a selected row or column, you should override this method and
fill in a more specific rectangle.getFocusedRect
in class View
r
- The rectangle to fill in, in this view's coordinates.public int getLineCount()
public int getLineBounds(int line, Rect bounds)
line
- which line to examine (0..getLineCount() - 1)bounds
- Optional. If not null, it returns the extent of the linepublic int getBaseline()
View
Return the offset of the widget's text baseline from the widget's top boundary. If this widget does not support baseline alignment, this method returns -1.
getBaseline
in class View
protected int getFadeTop(boolean offsetRequired)
getFadeTop
in class View
protected int getFadeHeight(boolean offsetRequired)
getFadeHeight
in class View
public boolean onKeyPreIme(int keyCode, KeyEvent event)
View
onKeyPreIme
in class View
keyCode
- The value in event.getKeyCode().event
- Description of the key event.public boolean onKeyDown(int keyCode, KeyEvent event)
View
KeyEvent.Callback.onKeyDown()
: perform press of the view
when KeyEvent.KEYCODE_DPAD_CENTER
or KeyEvent.KEYCODE_ENTER
is released, if the view is enabled and clickable.
Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.
onKeyDown
in interface KeyEvent.Callback
onKeyDown
in class View
keyCode
- A key code that represents the button pressed, from
KeyEvent
.event
- The KeyEvent object that defines the button action.public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event)
View
KeyEvent.Callback.onKeyMultiple()
: always returns false (doesn't handle
the event).
Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.
onKeyMultiple
in interface KeyEvent.Callback
onKeyMultiple
in class View
keyCode
- A key code that represents the button pressed, from
KeyEvent
.repeatCount
- The number of times the action was made.event
- The KeyEvent object that defines the button action.public void resetErrorChangedFlag()
setError(CharSequence)
can be recorded.public void hideErrorIfUnchanged()
public boolean onKeyUp(int keyCode, KeyEvent event)
View
KeyEvent.Callback.onKeyUp()
: perform clicking of the view
when KeyEvent.KEYCODE_DPAD_CENTER
or
KeyEvent.KEYCODE_ENTER
is released.
Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.
onKeyUp
in interface KeyEvent.Callback
onKeyUp
in class View
keyCode
- A key code that represents the button pressed, from
KeyEvent
.event
- The KeyEvent object that defines the button action.public boolean onCheckIsTextEditor()
View
View.onCreateInputConnection(EditorInfo)
to return true if
a call on that method would return a non-null InputConnection, and
they are really a first-class editor that the user would normally
start typing on when the go into a window containing your view.
The default implementation always returns false. This does
not mean that its View.onCreateInputConnection(EditorInfo)
will not be called or the user can not otherwise perform edits on your
view; it is just a hint to the system that this is not the primary
purpose of this view.
onCheckIsTextEditor
in class View
public InputConnection onCreateInputConnection(EditorInfo outAttrs)
View
When implementing this, you probably also want to implement
View.onCheckIsTextEditor()
to indicate you will return a
non-null InputConnection.
onCreateInputConnection
in class View
outAttrs
- Fill in with attribute information about the connection.public boolean extractText(ExtractedTextRequest request, ExtractedText outText)
public void setExtractedText(ExtractedText text)
extractText(ExtractedTextRequest, ExtractedText)
.public void setExtracting(ExtractedTextRequest req)
public void onCommitCompletion(CompletionInfo text)
InputConnection.commitCompletion()
. The default implementation does
nothing; text views that are supporting auto-completion should override
this to do their desired behavior.text
- The auto complete text the user has selected.public void onCommitCorrection(CorrectionInfo info)
InputConnection.commitCorrection(android.view.inputmethod.CorrectionInfo)
InputConnection.commitCorrection()}. The default
implementation flashes the background of the corrected word to provide feedback to the user.info
- The auto correct info about the text that was corrected.public void beginBatchEdit()
public void endBatchEdit()
public void onBeginBatchEdit()
beginBatchEdit()
.public void onEndBatchEdit()
endBatchEdit()
.public boolean onPrivateIMECommand(String action, Bundle data)
InputConnection.performPrivateCommand()
.action
- The action name of the command.data
- Any additional data for the command. This may be null.public void onRtlPropertiesChanged(int layoutDirection)
View
onRtlPropertiesChanged
in class View
layoutDirection
- the direction of the layoutView.LAYOUT_DIRECTION_LTR
,
View.LAYOUT_DIRECTION_RTL
protected void makeNewLayout(int wantWidth, int hintWidth, BoringLayout.Metrics boring, BoringLayout.Metrics hintBoring, int ellipsisWidth, boolean bringIntoView)
public void setIncludeFontPadding(boolean includepad)
getIncludeFontPadding()
public boolean getIncludeFontPadding()
setIncludeFontPadding(boolean)
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
View
Measure the view and its content to determine the measured width and the
measured height. This method is invoked by View.measure(int, int)
and
should be overriden by subclasses to provide accurate and efficient
measurement of their contents.
CONTRACT: When overriding this method, you
must call View.setMeasuredDimension(int, int)
to store the
measured width and height of this view. Failure to do so will trigger an
IllegalStateException
, thrown by
View.measure(int, int)
. Calling the superclass'
View.onMeasure(int, int)
is a valid use.
The base class implementation of measure defaults to the background size,
unless a larger size is allowed by the MeasureSpec. Subclasses should
override View.onMeasure(int, int)
to provide better measurements of
their content.
If this method is overridden, it is the subclass's responsibility to make
sure the measured height and width are at least the view's minimum height
and width (View.getSuggestedMinimumHeight()
and
View.getSuggestedMinimumWidth()
).
onMeasure
in class View
widthMeasureSpec
- horizontal space requirements as imposed by the parent.
The requirements are encoded with
View.MeasureSpec
.heightMeasureSpec
- vertical space requirements as imposed by the parent.
The requirements are encoded with
View.MeasureSpec
.View.getMeasuredWidth()
,
View.getMeasuredHeight()
,
View.setMeasuredDimension(int, int)
,
View.getSuggestedMinimumHeight()
,
View.getSuggestedMinimumWidth()
,
View.MeasureSpec.getMode(int)
,
View.MeasureSpec.getSize(int)
protected void onLayout(boolean changed, int left, int top, int right, int bottom)
View
public boolean bringPointIntoView(int offset)
public boolean moveCursorToVisibleOffset()
public void computeScroll()
View
Scroller
object.computeScroll
in class View
public void debug(int depth)
View
View.VIEW_LOG_TAG
. Each line in the output is preceded with an
indentation defined by the depth
.public int getSelectionStart()
Selection.getSelectionStart(java.lang.CharSequence)
.public int getSelectionEnd()
Selection.getSelectionEnd(java.lang.CharSequence)
.public boolean hasSelection()
public void setSingleLine()
public void setAllCaps(boolean allCaps)
public void setSingleLine(boolean singleLine)
public void setEllipsize(TextUtils.TruncateAt where)
setSingleLine()
or setHorizontallyScrolling(boolean)
to constrain the text to a single line. Use null
to turn off ellipsizing.
If setMaxLines(int)
has been used to set two or more lines,
TextUtils.TruncateAt.END
and
TextUtils.TruncateAt.MARQUEE
* are only supported
(other ellipsizing types will not do anything).public void setMarqueeRepeatLimit(int marqueeLimit)
getMarqueeRepeatLimit()
public int getMarqueeRepeatLimit()
setMarqueeRepeatLimit(int)
public TextUtils.TruncateAt getEllipsize()
public void setSelectAllOnFocus(boolean selectAllOnFocus)
public void setCursorVisible(boolean visible)
isCursorVisible()
public boolean isCursorVisible()
setCursorVisible(boolean)
protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter)
text
, the lengthAfter
characters
beginning at start
have just replaced old text that had
length lengthBefore
. It is an error to attempt to make
changes to text
from this callback.text
- The text the TextView is displayingstart
- The offset of the start of the range of the text that was
modifiedlengthBefore
- The length of the former text that has been replacedlengthAfter
- The length of the replacement modified textprotected void onSelectionChanged(int selStart, int selEnd)
selStart
- The new selection start location.selEnd
- The new selection end location.public void addTextChangedListener(TextWatcher watcher)
In 1.0, the TextWatcher.afterTextChanged(android.text.Editable)
method was erroneously
not called after setText(java.lang.CharSequence)
calls. Now, doing setText(java.lang.CharSequence)
if there are any text changed listeners forces the buffer type to
Editable if it would not otherwise be and does call this method.
public void removeTextChangedListener(TextWatcher watcher)
public void dispatchFinishTemporaryDetach()
dispatchFinishTemporaryDetach
in class View
public void onStartTemporaryDetach()
View
ViewGroup.detachViewFromParent
.
It will either be followed by View.onFinishTemporaryDetach()
or
View.onDetachedFromWindow()
when the container is done.onStartTemporaryDetach
in class View
public void onFinishTemporaryDetach()
View
View.onStartTemporaryDetach()
when the container is done
changing the view.onFinishTemporaryDetach
in class View
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect)
View
onFocusChanged
in class View
focused
- True if the View has focus; false otherwise.direction
- The direction focus has moved when requestFocus()
is called to give this view focus. Values are
View.FOCUS_UP
, View.FOCUS_DOWN
, View.FOCUS_LEFT
,
View.FOCUS_RIGHT
, View.FOCUS_FORWARD
, or View.FOCUS_BACKWARD
.
It may not always apply, in which case use the default.previouslyFocusedRect
- The rectangle, in this view's coordinate
system, of the previously focused view. If applicable, this will be
passed in as finer grained information about where the focus is coming
from (in addition to direction). Will be null
otherwise.public void onWindowFocusChanged(boolean hasWindowFocus)
View
onWindowFocusChanged
in class View
hasWindowFocus
- True if the window containing this view now has
focus, false otherwise.protected void onVisibilityChanged(View changedView, int visibility)
View
onVisibilityChanged
in class View
changedView
- The view whose visibility changed. Could be 'this' or
an ancestor view.visibility
- The new visibility of changedView: View.VISIBLE
,
View.INVISIBLE
or View.GONE
.public void clearComposingText()
BaseInputConnection.removeComposingSpans()
to remove any IME composing
state from this text view.public void setSelected(boolean selected)
View
setSelected
in class View
selected
- true if the view must be selected, false otherwisepublic boolean onTouchEvent(MotionEvent event)
View
onTouchEvent
in class View
event
- The motion event.public boolean onGenericMotionEvent(MotionEvent event)
View
Generic motion events describe joystick movements, mouse hovers, track pad
touches, scroll wheel movements and other input events. The
source
of the motion event specifies
the class of input that was received. Implementations of this method
must examine the bits in the source before processing the event.
The following code example shows how this is done.
Generic motion events with source class InputDevice.SOURCE_CLASS_POINTER
are delivered to the view under the pointer. All other generic motion events are
delivered to the focused view.
public boolean onGenericMotionEvent(MotionEvent event) { if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { if (event.getAction() == MotionEvent.ACTION_MOVE) { // process the joystick movement... return true; } } if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { switch (event.getAction()) { case MotionEvent.ACTION_HOVER_MOVE: // process the mouse hover movement... return true; case MotionEvent.ACTION_SCROLL: // process the scroll wheel movement... return true; } } return super.onGenericMotionEvent(event); }
onGenericMotionEvent
in class View
event
- The generic motion event being processed.public boolean didTouchFocusSelect()
public void cancelLongPress()
View
cancelLongPress
in class View
public boolean onTrackballEvent(MotionEvent event)
View
MotionEvent.getX()
and
MotionEvent.getY()
. These are normalized so
that a movement of 1 corresponds to the user pressing one DPAD key (so
they will often be fractional values, representing the more fine-grained
movement information available from a trackball).onTrackballEvent
in class View
event
- The motion event.public void setScroller(Scroller s)
protected float getLeftFadingEdgeStrength()
View
getLeftFadingEdgeStrength
in class View
protected float getRightFadingEdgeStrength()
View
getRightFadingEdgeStrength
in class View
protected int computeHorizontalScrollRange()
View
Compute the horizontal range that the horizontal scrollbar represents.
The range is expressed in arbitrary units that must be the same as the
units used by View.computeHorizontalScrollExtent()
and
View.computeHorizontalScrollOffset()
.
The default range is the drawing width of this view.
computeHorizontalScrollRange
in class View
View.computeHorizontalScrollExtent()
,
View.computeHorizontalScrollOffset()
,
ScrollBarDrawable
protected int computeVerticalScrollRange()
View
Compute the vertical range that the vertical scrollbar represents.
The range is expressed in arbitrary units that must be the same as the
units used by View.computeVerticalScrollExtent()
and
View.computeVerticalScrollOffset()
.
computeVerticalScrollRange
in class View
The default range is the drawing height of this view.
View.computeVerticalScrollExtent()
,
View.computeVerticalScrollOffset()
,
ScrollBarDrawable
protected int computeVerticalScrollExtent()
View
Compute the vertical extent of the horizontal scrollbar's thumb within the vertical range. This value is used to compute the length of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the
units used by View.computeVerticalScrollRange()
and
View.computeVerticalScrollOffset()
.
The default extent is the drawing height of this view.
computeVerticalScrollExtent
in class View
View.computeVerticalScrollRange()
,
View.computeVerticalScrollOffset()
,
ScrollBarDrawable
public void findViewsWithText(ArrayList<View> outViews, CharSequence searched, int flags)
View
View.FIND_VIEWS_WITH_TEXT
and
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION
flags.findViewsWithText
in class View
outViews
- The output list of matching Views.searched
- The text to match against.View.FIND_VIEWS_WITH_TEXT
,
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION
,
View.setContentDescription(CharSequence)
public static ColorStateList getTextColors(Context context, TypedArray attrs)
public static int getTextColor(Context context, TypedArray attrs, int def)
public boolean onKeyShortcut(int keyCode, KeyEvent event)
View
shortcut
property of menu items.onKeyShortcut
in class View
keyCode
- The value in event.getKeyCode().event
- Description of the key event.public Locale getTextServicesLocale()
public WordIterator getWordIterator()
public void onPopulateAccessibilityEvent(AccessibilityEvent event)
View
View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)
giving a chance to this View to populate the accessibility event with its
text content. While this method is free to modify event
attributes other than text content, doing so should normally be performed in
View.onInitializeAccessibilityEvent(AccessibilityEvent)
.
Example: Adding formatted date string to an accessibility event in addition to the text added by the super implementation:
public void onPopulateAccessibilityEvent(AccessibilityEvent event) { super.onPopulateAccessibilityEvent(event); final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY; String selectedDateUtterance = DateUtils.formatDateTime(mContext, mCurrentDate.getTimeInMillis(), flags); event.getText().add(selectedDateUtterance); }
If an View.AccessibilityDelegate
has been specified via calling
View.setAccessibilityDelegate(AccessibilityDelegate)
its
View.AccessibilityDelegate.onPopulateAccessibilityEvent(View, AccessibilityEvent)
is responsible for handling this call.
Note: Always call the super implementation before adding information to the event, in case the default implementation has basic information to add.
onPopulateAccessibilityEvent
in class View
event
- The accessibility event which to populate.View.sendAccessibilityEvent(int)
,
View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)
public void onInitializeAccessibilityEvent(AccessibilityEvent event)
View
AccessibilityEvent
with information about
this View which is the event source. In other words, the source of
an accessibility event is the view whose state change triggered firing
the event.
Example: Setting the password property of an event in addition to properties set by the super implementation:
public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setPassword(true); }
If an View.AccessibilityDelegate
has been specified via calling
View.setAccessibilityDelegate(AccessibilityDelegate)
its
View.AccessibilityDelegate.onInitializeAccessibilityEvent(View, AccessibilityEvent)
is responsible for handling this call.
Note: Always call the super implementation before adding information to the event, in case the default implementation has basic information to add.
onInitializeAccessibilityEvent
in class View
event
- The event to initialize.View.sendAccessibilityEvent(int)
,
View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)
View
AccessibilityNodeInfo
with information about this view.
The base implementation sets:
AccessibilityNodeInfo.setParent(View)
,AccessibilityNodeInfo.setBoundsInParent(Rect)
,AccessibilityNodeInfo.setBoundsInScreen(Rect)
,AccessibilityNodeInfo.setPackageName(CharSequence)
,AccessibilityNodeInfo.setClassName(CharSequence)
,AccessibilityNodeInfo.setContentDescription(CharSequence)
,AccessibilityNodeInfo.setEnabled(boolean)
,AccessibilityNodeInfo.setClickable(boolean)
,AccessibilityNodeInfo.setFocusable(boolean)
,AccessibilityNodeInfo.setFocused(boolean)
,AccessibilityNodeInfo.setLongClickable(boolean)
,AccessibilityNodeInfo.setSelected(boolean)
,Subclasses should override this method, call the super implementation, and set additional attributes.
If an View.AccessibilityDelegate
has been specified via calling
View.setAccessibilityDelegate(AccessibilityDelegate)
its
View.AccessibilityDelegate.onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfo)
is responsible for handling this call.
onInitializeAccessibilityNodeInfo
in class View
info
- The instance to initialize.public void sendAccessibilityEvent(int eventType)
View
View.onInitializeAccessibilityEvent(AccessibilityEvent)
first
to populate information about the event source (this View), then calls
View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)
to
populate the text content of the event source including its descendants,
and last calls
ViewParent.requestSendAccessibilityEvent(View, AccessibilityEvent)
on its parent to resuest sending of the event to interested parties.
If an View.AccessibilityDelegate
has been specified via calling
View.setAccessibilityDelegate(AccessibilityDelegate)
its
View.AccessibilityDelegate.sendAccessibilityEvent(View, int)
is
responsible for handling this call.
sendAccessibilityEvent
in interface AccessibilityEventSource
sendAccessibilityEvent
in class View
eventType
- The type of the event to send, as defined by several types from
AccessibilityEvent
, such as
AccessibilityEvent.TYPE_VIEW_CLICKED
or
AccessibilityEvent.TYPE_VIEW_HOVER_ENTER
.View.onInitializeAccessibilityEvent(AccessibilityEvent)
,
View.dispatchPopulateAccessibilityEvent(AccessibilityEvent)
,
ViewParent.requestSendAccessibilityEvent(View, AccessibilityEvent)
,
View.AccessibilityDelegate
public CharSequence getTextForAccessibility()
public boolean isInputMethodTarget()
InputMethodManager
.public boolean onTextContextMenuItem(int id)
android.R.id#selectAll
, android.R.id#cut
,
android.R.id#copy
or android.R.id#paste
.public boolean performLongClick()
View
performLongClick
in class View
protected void onScrollChanged(int horiz, int vert, int oldHoriz, int oldVert)
View
View.scrollBy(int, int)
or View.scrollTo(int, int)
having been
called.onScrollChanged
in class View
horiz
- Current horizontal scroll origin.vert
- Current vertical scroll origin.oldHoriz
- Previous horizontal scroll origin.oldVert
- Previous vertical scroll origin.public boolean isSuggestionsEnabled()
SuggestionSpan
s to the text.
When suggestions are enabled (default), this list of suggestions will be displayed when the
user asks for them on these parts of the text. This value depends on the inputType of this
TextView.
The class of the input type must be InputType.TYPE_CLASS_TEXT
.
In addition, the type variation must be one of
InputType.TYPE_TEXT_VARIATION_NORMAL
,
InputType.TYPE_TEXT_VARIATION_EMAIL_SUBJECT
,
InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE
,
InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE
or
InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT
.
And finally, the InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
flag must not be set.public void setCustomSelectionActionModeCallback(ActionMode.Callback actionModeCallback)
ActionMode.Callback.onPrepareActionMode(ActionMode, Menu)
method. The
default actions can also be removed from the menu using Menu.removeItem(int)
and
passing android.R.id#selectAll
, android.R.id#cut
, android.R.id#copy
or android.R.id#paste
ids as parameters.
Returning false from
ActionMode.Callback.onCreateActionMode(ActionMode, Menu)
will prevent
the action mode from being started.
Action click events should be handled by the custom implementation of
ActionMode.Callback.onActionItemClicked(ActionMode, MenuItem)
.
Note that text selection mode is not started when a TextView receives focus and the
android.R.attr#selectAllOnFocus
flag has been set. The content is highlighted in
that case, to allow for quick replacement.public ActionMode.Callback getCustomSelectionActionModeCallback()
setCustomSelectionActionModeCallback(android.view.ActionMode.Callback)
. Default is null.protected void stopSelectionActionMode()
public int getOffsetForPosition(float x, float y)
MotionEvent.getX()
and MotionEvent.getY()
to this method.x
- The horizontal absolute position of a point on screeny
- The vertical absolute position of a point on screenpublic boolean onDragEvent(DragEvent event)
View
startDrag()
.
When the system calls this method, it passes a
DragEvent
object. A call to
DragEvent.getAction()
returns one of the action type constants defined
in DragEvent. The method uses these to determine what is happening in the drag and drop
operation.
onDragEvent
in class View
event
- The DragEvent
sent by the system.
The DragEvent.getAction()
method returns an action type constant defined
in DragEvent, indicating the type of drag event represented by this object.true
if the method was successful, otherwise false
.
The method should return true
in response to an action type of
DragEvent.ACTION_DRAG_STARTED
to receive drag events for the current
operation.
The method should also return true
in response to an action type of
DragEvent.ACTION_DROP
if it consumed the drop, or
false
if it didn't.
public void onResolveDrawables(int layoutDirection)
View
onResolveDrawables
in class View
layoutDirection
- The resolved layout direction.View.LAYOUT_DIRECTION_LTR
,
View.LAYOUT_DIRECTION_RTL
protected void resetResolvedDrawables()
resetResolvedDrawables
in class View
protected void viewClicked(InputMethodManager imm)
protected void deleteText_internal(int start, int end)
protected void replaceText_internal(int start, int end, CharSequence text)
protected void setSpan_internal(Object span, int start, int end, int flags)
protected void setCursorPosition_internal(int start, int end)
public CharSequence getIterableTextForAccessibility()
View
getIterableTextForAccessibility
in class View
public AccessibilityIterators.TextSegmentIterator getIteratorForGranularity(int granularity)
getIteratorForGranularity
in class View
public int getAccessibilityCursorPosition()
getAccessibilityCursorPosition
in class View
public void setAccessibilityCursorPosition(int index)
setAccessibilityCursorPosition
in class View