Class TextView
- All Implemented Interfaces:
Drawable.Callback,ViewTreeObserver.OnPreDrawListener
EditText.
To display a styled text, use a Spannable with markup objects, like CharacterStyle.
TextView will hold a copy of your text after calling setText(CharSequence, BufferType).
After you provide a String, you want it to have styles:
TextView textView = new TextView(); textView.setText(string, TextView.BufferType.SPANNABLE); // add styles Spannable spannable = (Spannable) textView.getText(); spannable.setSpan(new ForegroundColorSpan(0xfff699b4), 0, 8, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);If you want a non-editable text to be selected, see
setTextIsSelectable(boolean).
Explore the methods in this class to find more usage
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumType of the text buffer that defines the characteristics of the text such as static, styleable, or editable.Nested classes/interfaces inherited from class icyllis.modernui.view.View
View.DragShadow, View.Focusable, View.FocusableMode, View.FocusDirection, View.FocusRealDirection, View.LayoutDir, View.NestedScrollType, View.OnAttachStateChangeListener, View.OnClickListener, View.OnContextClickListener, View.OnCreateContextMenuListener, View.OnDragListener, View.OnFocusChangeListener, View.OnGenericMotionListener, View.OnHoverListener, View.OnKeyListener, View.OnLayoutChangeListener, View.OnLongClickListener, View.OnScrollChangeListener, View.OnTouchListener, View.ResolvedLayoutDir, View.ScrollAxis, View.ScrollBarStyle, View.ScrollIndicators, View.TextAlignment, View.Visibility -
Field Summary
FieldsFields inherited from class icyllis.modernui.view.View
ALPHA, BOTTOM, 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, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLE, FOCUSABLE_AUTO, 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, INVISIBLE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, LAYOUT_DIRECTION_UNDEFINED, LEFT, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, NO_ID, NOT_FOCUSABLE, 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, RIGHT, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCROLL_AXIS_HORIZONTAL, SCROLL_AXIS_NONE, SCROLL_AXIS_VERTICAL, SCROLL_INDICATOR_BOTTOM, SCROLL_INDICATOR_END, SCROLL_INDICATOR_LEFT, SCROLL_INDICATOR_RIGHT, SCROLL_INDICATOR_START, SCROLL_INDICATOR_TOP, SCROLL_X, SCROLL_Y, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, 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_FIRST_STRONG_LTR, TEXT_DIRECTION_FIRST_STRONG_RTL, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TOP, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, TYPE_NON_TOUCH, TYPE_TOUCH, VIEW_MARKER, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y, Z -
Constructor Summary
ConstructorsConstructorDescriptionSimple constructor to use when creating a text view from code.TextView(Context context, AttributeSet attrs) TextView(Context context, AttributeSet attrs, ResourceId defStyleAttr) TextView(Context context, AttributeSet attrs, ResourceId defStyleAttr, ResourceId defStyleRes) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTextChangedListener(TextWatcher watcher) Adds a TextWatcher to the list of those whose methods are called whenever this TextView's text changes.booleanbringPointIntoView(int offset) Move the point, specified by the offset, into the view if it is needed.voidCancels a pending long press.protected intCompute the horizontal range that the horizontal scrollbar represents.protected intCompute the vertical extent of the vertical scrollbar's thumb within the vertical range.protected intCompute the vertical range that the vertical scrollbar represents.booleanReturns 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.voiddrawableHotspotChanged(float x, float y) This function is called whenever the view hotspot changes and needs to be propagated to drawables or child views managed by the view.protected voidThis function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.final intGets the autolink mask of the text.intReturn the offset of the widget's text baseline from the widget's top boundary.intReturns the padding between the compound drawables and the text.Drawable[]Returns drawables for the left, top, right, and bottom borders.Drawable[]Returns drawables for the start, top, end, and bottom borders.Returns the blending mode used to apply the tint to the compound drawables, if specified.intReturns the bottom padding of the view, plus space for the bottom Drawable if any.intReturns the end padding of the view, plus space for the end Drawable if any.intReturns the left padding of the view, plus space for the left Drawable if any.intReturns the right padding of the view, plus space for the right Drawable if any.intReturns the start padding of the view, plus space for the start Drawable if any.intReturns the top padding of the view, plus space for the top Drawable if any.final intReturn the current color selected to paint the hint text.final intReturn the current color selected for normal text.protected booleanSubclasses override this to specify that they have a KeyListener by default even if not specifically called for in the XML options.protected MovementMethodSubclasses override this to specify a default movement method.Return the text that TextView is displaying as an Editable object.Returns where, if anywhere, words that are longer than the view is wide should be ellipsized.intReturns 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.intReturns 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.Returns the current list of input filters.intReturns the distance between the first text baseline and the top of this TextView.voidWhen 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.intReturns the horizontal and vertical alignment of this TextView.intgetHint()Returns the hint that is displayed when the text of the TextView is empty.final ColorStateListbooleanGets whether the TextView includes extra top and bottom padding to make room for accents that go above the normal ascent and descent.intReturns the distance between the last text baseline and the bottom of this TextView.final LayoutGets theLayoutthat is currently being used to display the text.intgetLineBounds(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.intGet the current line break style for text wrapping.intGet the current line word break style for text wrapping.intReturn the number of lines of text, or 0 if the internal Layout has not been built.intGets the vertical distance between lines of text, in pixels.floatReturns the amount added to the line height.floatReturns the multiplier applied to the line height.final booleanReturns whether the movement method will automatically be set toLinkMovementMethodifsetAutoLinkMask(int)has been set to nonzero and links are detected insetText(java.lang.CharSequence).final ColorStateListintReturns the maximum height of TextView in terms of pixels or -1 if the maximum height was set usingsetMaxLines(int)orsetLines(int).intReturns the maximum height of TextView in terms of number of lines or -1 if the maximum height was set usingsetMaxHeight(int)orsetHeight(int).intReturns the maximum width of TextView in terms of pixels.intReturns the minimum height of TextView in terms of pixels or -1 if the minimum height was set usingsetMinLines(int)orsetLines(int).intReturns the minimum height of TextView in terms of number of lines or -1 if the minimum height was set usingsetMinHeight(int)orsetHeight(int).intReturns the minimum width of TextView in terms of pixels.final MovementMethodGets theMovementMethodbeing used for this TextView, which provides positioning, scrolling, and text selection functionality.intgetOffsetForPosition(float x, float y) Get the character offset closest to the specified absolute position.getPaint()Gets theTextPaintused for the text.intConvenience forSelection.getSelectionEnd(java.lang.CharSequence).intConvenience forSelection.getSelectionStart(java.lang.CharSequence).getText()Return the text that TextView is displaying.final ColorStateListGets the text colors for the different states (normal, selected, focused) of the TextView.Returns resolvedTextDirectionHeuristicthat will be used for text layout.Get the default primaryLocaleof the text in this TextView.Gets the parameters for text layout pre-computation, for use withPrecomputedText.floatintGets the text size unit defined by the developer.intGets the current text style that is used to style the text.intReturns 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.intReturns the total end padding of the view, including the end Drawable if any.intReturns the total left padding of the view, including the left Drawable if any.intReturns the total right padding of the view, including the right Drawable if any.intReturns the total start padding of the view, including the start Drawable if any.intReturns 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.final TransformationMethodGets the currentTransformationMethodfor the TextView.Gets the currentTypefacethat is used to style the text.booleanReturn true iff there is a selection of nonzero length inside this text view.voidinvalidateDrawable(Drawable drawable) Invalidates the specified Drawable.booleanbooleanfinal booleanReturns whether the text is allowed to be wider than the View.booleanReturns the state of thetextIsSelectableflag (SeesetTextIsSelectable()).voidCallDrawable.jumpToCurrentState()on all Drawable objects associated with this view.final voidmakeNewLayout(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.booleanMove the cursor, if needed, so that it is at an offset that is visible to the user.protected voidThis is called when the view is attached to a window.protected voidViews should implement this if the view itself is going to add items to the context menu.protected int[]onCreateDrawableState(int extraSpace) Generate the newDrawablestate for this view.protected voidThis is called when the view is detached from a window.protected voidDraw the content of this view, implement this to do your drawing.protected voidonFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) Called by the view system when the focus state of this view changes.booleanonGenericMotionEvent(MotionEvent event) Implement this method to handle generic motion events.booleanDefault implementation: perform press of the view whenKeyEvent.KEY_ENTER,KeyEvent.KEY_KP_ENTERorKeyEvent.KEY_SPACEis released, if the view is enabled and clickable.booleanonKeyShortcut(int keyCode, KeyEvent event) Called on the focused view when a key shortcut event is not handled.booleanDefault implementation: perform clicking of the view whenKeyEvent.KEY_ENTER,KeyEvent.KEY_KP_ENTERorKeyEvent.KEY_SPACEis released.protected voidonLayout(boolean changed, int left, int top, int right, int bottom) Called fromView.layout(int, int, int, int)when this view should assign a size and position to each of its children.protected voidonMeasure(int widthMeasureSpec, int heightMeasureSpec) Measure the view and its content to determine the measured width and the measured height.booleanCallback method to be invoked when the view tree is about to be drawn.onResolvePointerIcon(MotionEvent event) Returns the pointer icon for the motion event, or null if it doesn't specify the icon.protected voidonRtlPropertiesChanged(int layoutDirection) Called when any RTL property (layout direction or text direction or text alignment) has been changed.protected voidonTextChanged(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.booleanonTextContextMenuItem(int id) Called when a context menu option for the text view is selected.booleanonTouchEvent(MotionEvent event) Implement this method to handle touch screen motion events.voidremoveTextChangedListener(TextWatcher watcher) Removes the specified TextWatcher from the list of those whose methods are called whenever this TextView's text changes.final voidsetAutoLinkMask(int mask) Sets the autolink mask of the text.voidsetCompoundDrawablePadding(int pad) Sets the size of the padding between the compound drawables and the text.voidsetCompoundDrawables(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.voidsetCompoundDrawablesRelative(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.voidsetCompoundDrawablesRelativeWithIntrinsicBounds(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.voidsetCompoundDrawablesWithIntrinsicBounds(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.voidsetCompoundDrawableTintBlendMode(BlendMode blendMode) Specifies the blending mode used to apply the tint specified bysetCompoundDrawableTintList(ColorStateList)to the compound drawables.voidApplies a tint to the compound drawables.voidsetCursorVisible(boolean visible) Set whether the cursor is visible.final voidsetEditableFactory(Editable.Factory factory) Sets the Factory used to create newEditables.voidsetEllipsize(TextUtils.TruncateAt where) Causes words in the text that are longer than the view's width to be ellipsized instead of broken in the middle.voidsetEnabled(boolean enabled) Set the enabled state of this view.voidsetFallbackLineSpacing(boolean enabled) Set whether to respect the ascent and descent of the fallback fonts that are used in displaying the text (which is needed to avoid text from consecutive lines running into each other).voidsetFilters(InputFilter... filters) Sets the list of input filters that will be used if the buffer is Editable.voidsetFirstBaselineToTopHeight(int firstBaselineToTopHeight) Updates the top padding of the TextView so thatfirstBaselineToTopHeightis the distance between the top of the TextView and first line's baseline.voidsetGravity(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.voidsetHeight(int pixels) Sets the height of the TextView to be exactlypixelstall.voidsetHighlightColor(int color) Sets the color used to display the selection highlight.final voidsetHint(CharSequence hint) Sets the text to be displayed when the text of the TextView is empty.final voidsetHintTextColor(int color) Sets the color of the hint text for all the states (disabled, focussed, selected...) of this TextView.final voidsetHintTextColor(ColorStateList colors) Sets the color of the hint text.voidsetHorizontallyScrolling(boolean whether) Sets whether the text should be allowed to be wider than the View is.voidsetIncludeFontPadding(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.voidsetLastBaselineToBottomHeight(int lastBaselineToBottomHeight) Updates the bottom padding of the TextView so thatlastBaselineToBottomHeightis the distance between the bottom of the TextView and the last line's baseline.voidsetLineBreakStyle(int lineBreakStyle) Set the line break style for text wrapping.voidsetLineBreakWordStyle(int lineBreakWordStyle) Set the line break word style for text wrapping.voidsetLineHeight(int lineHeight) Sets an explicit line height for this TextView.voidsetLineHeight(int unit, float lineHeight) Sets an explicit line height to a given unit and value for this TextView.voidsetLines(int lines) Sets the height of the TextView to be exactlylinestall.voidsetLineSpacing(float add, float mult) Sets line spacing for this TextView.final voidsetLinksClickable(boolean whether) Sets whether the movement method will automatically be set toLinkMovementMethodifsetAutoLinkMask(int)has been set to nonzero and links are detected insetText(java.lang.CharSequence).final voidsetLinkTextColor(int color) Sets the color of links in the text.final voidsetLinkTextColor(ColorStateList colors) Sets the color of links in the text.voidsetMaxHeight(int maxPixels) Sets the height of the TextView to be at mostmaxPixelstall.voidsetMaxLines(int maxLines) Sets the height of the TextView to be at mostmaxLinestall.voidsetMaxWidth(int maxPixels) Sets the width of the TextView to be at mostmaxPixelswide.voidsetMinHeight(int minPixels) Sets the height of the TextView to be at leastminPixelstall.voidsetMinLines(int minLines) Sets the height of the TextView to be at leastminLinestall.voidsetMinWidth(int minPixels) Sets the width of the TextView to be at leastminPixelswide.final voidsetMovementMethod(MovementMethod movement) Sets theMovementMethodfor handling arrow key movement for this TextView.voidsetPadding(int left, int top, int right, int bottom) Sets the padding.voidsetPaddingRelative(int start, int top, int end, int bottom) Sets the relative padding.voidsetSelectAllOnFocus(boolean selectAllOnFocus) Set the TextView so that when it takes focus, all the text is selected.voidSets the properties of this field (lines, horizontally scrolling, transformation method) to be for a single-line input.voidsetSingleLine(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.final voidsetSpannableFactory(Spannable.Factory factory) Sets the Factory used to create newSpannables.final voidsetText(CharSequence text) Sets the text to be displayed.voidsetText(CharSequence text, TextView.BufferType type) Sets the text to be displayed and theTextView.BufferType.voidsetTextAppearance(ResourceId resId) Sets the text appearance from the specified style resource.voidsetTextAppearance(icyllis.modernui.resources.TextAppearance textAppearance) Sets the text appearance.voidsetTextColor(int color) Sets the text color for all the states (normal, selected, focused) to be this color.voidsetTextColor(ColorStateList colors) Sets the text color.voidsetTextIsSelectable(boolean selectable) Sets whether the content of this view is selectable by the user.final voidsetTextKeepState(CharSequence text) Sets the text to be displayed but retains the cursor position.final voidsetTextKeepState(CharSequence text, TextView.BufferType type) Sets the text to be displayed and theTextView.BufferTypebut retains the cursor position.voidsetTextLocale(Locale locale) Set the defaultLocaleof the text in this TextView to the given Locale.voidApply the text layout parameter.voidsetTextSize(float size) Set the default text size to the given value, interpreted as "scaled pixel" units.voidsetTextSize(int unit, float size) Set the default text size to a given unit and value.voidsetTextStyle(int style) Sets the default text style in which the text should be displayed.final voidSets the transformation that is applied to the text that this TextView is displaying.voidsetTypeface(Typeface tf) Sets the typeface in which the text should be displayed.voidsetWidth(int pixels) Sets the width of the TextView to be exactlypixelswide.booleanshowContextMenu(float x, float y) Shows the context menu for this view anchored to the specified view-relative coordinate.protected booleanverifyDrawable(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.Methods inherited from class icyllis.modernui.view.View
addFocusables, addFocusables, addKeyboardNavigationClusters, addOnAttachStateChangeListener, addOnLayoutChangeListener, addTouchables, awakenScrollBars, awakenScrollBars, callOnClick, cancelPendingInputEvents, canReceivePointerEvents, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, clearFocus, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeScroll, computeVerticalScrollOffset, createContextMenu, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchGenericMotionEvent, dispatchGenericPointerEvent, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPointerEvent, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchTouchEvent, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, dp, draw, findFocus, findViewById, findViewByPredicate, findViewByPredicateInsideOut, findViewWithTag, focusSearch, forceHasOverlappingRendering, forceLayout, generateViewId, getAlpha, getAnimationMatrix, getBackground, getBottom, getBoundsOnScreen, getBoundsOnScreen, getClipBounds, getClipBounds, getContentDescription, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingRect, getElevation, getFadingEdge, getFadingEdgeLength, getFocusable, getFocusables, getForeground, getForegroundGravity, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalScrollbarHeight, getHorizontalScrollbarThumbDrawable, getHorizontalScrollbarTrackDrawable, getId, getInverseMatrix, getKeyDispatcherState, getLayoutDirection, getLayoutParams, getLeft, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextClusterForwardId, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOnLongClickListener, getOutlineProvider, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getPivotX, getPivotY, getRawLayoutDirection, getRawTextAlignment, getRawTextDirection, getRevealOnFocusHint, getRight, getRootView, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getStateDescription, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTag, getTextAlignment, getTextDirection, getTooltipText, getTooltipView, getTop, getTouchables, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getVerticalFadingEdgeLength, getVerticalScrollbarThumbDrawable, getVerticalScrollbarTrackDrawable, getVerticalScrollbarWidth, getViewRoot, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowVisibility, getX, getY, getZ, handleScrollBarDragging, hasExplicitFocusable, hasFocus, hasFocusable, hasIdentityMatrix, hasNestedScrollingParent, hasOnClickListeners, hasOnLongClickListeners, hasOverlappingRendering, hasTransientState, hasTranslationTransientState, hasWindowFocus, invalidate, invalidate, invalidate, invalidateOutline, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isFocusedByDefault, isForegroundInsidePadding, isHapticFeedbackEnabled, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isInLayout, isInScrollingContainer, isInTouchMode, isKeyboardNavigationCluster, isLaidOut, isLayoutDirectionInherited, isLayoutDirectionResolved, isLayoutRequested, isLayoutRtl, isLongClickable, isNestedScrollingEnabled, isPaddingRelative, isPivotSet, isPressed, isRootNamespace, isScrollbarFadingEnabled, isSelected, isShowingLayoutBounds, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentInherited, isTextAlignmentResolved, isTextDirectionInherited, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVerticalScrollBarHidden, keyboardNavigationClusterSearch, layout, mapRectFromViewToScreenCoords, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onCancelPendingInputEvents, onDragEvent, onDrawForeground, onDrawScrollBars, onFinishTemporaryDetach, onHoverChanged, onHoverEvent, onOverScrolled, onScrollChanged, onSizeChanged, onStartTemporaryDetach, onVisibilityAggregated, onVisibilityChanged, onWindowFocusChanged, onWindowVisibilityChanged, overScrollBy, performButtonActionOnTouchDown, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, playSoundEffect, pointInView, post, postDelayed, postInvalidate, postInvalidateDelayed, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestFocus, requestFocus, requestFocus, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, requireViewById, resetPivot, resetResolvedDrawables, resolveDrawables, resolveLayoutDirection, resolveLayoutParams, resolvePadding, resolveRtlPropertiesIfNeeded, resolveSize, resolveSizeAndState, resolveTextAlignment, resolveTextDirection, restoreDefaultFocus, scheduleDrawable, scrollBy, scrollTo, setActivated, setAlpha, setAnimationMatrix, setBackground, setBottom, setClickable, setClipBounds, setContentDescription, setContextClickable, setDuplicateParentStateEnabled, setElevation, setFocusable, setFocusable, setFocusableInTouchMode, setFocusedByDefault, setFocusedInCluster, setForeground, setForegroundGravity, setFrame, setHapticFeedbackEnabled, setHasTransientState, setHasTranslationTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHorizontalScrollbarThumbDrawable, setHorizontalScrollbarTrackDrawable, setHovered, setId, setIsRootNamespace, setKeyboardNavigationCluster, setLayoutDirection, setLayoutParams, setLeft, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextClusterForwardId, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnTouchListener, setOutlineProvider, setOverScrollMode, setPivotX, setPivotY, setPressed, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateDescription, setStateListAnimator, setTag, setTag, setTextAlignment, setTextDirection, setTooltipText, setTop, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarThumbDrawable, setVerticalScrollbarTrackDrawable, setVisibility, setWillNotDraw, setX, setY, setZ, showContextMenu, sp, startActionMode, startActionMode, startDragAndDrop, startNestedScroll, stopNestedScroll, toGlobalMotionEvent, toLocalMotionEvent, toString, transformFromViewToWindowSpace, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, unscheduleDrawable, willNotDraw
-
Field Details
-
UNKNOWN_BORING
-
-
Constructor Details
-
TextView
Simple constructor to use when creating a text view from code.- Parameters:
context- The Context the view is running in, through which it can access the current theme, resources, etc.
-
TextView
-
TextView
public TextView(Context context, @Nullable AttributeSet attrs, @Nullable @AttrRes ResourceId defStyleAttr) -
TextView
public TextView(Context context, @Nullable AttributeSet attrs, @Nullable @AttrRes ResourceId defStyleAttr, @Nullable @StyleRes ResourceId defStyleRes)
-
-
Method Details
-
getDefaultEditable
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. -
getDefaultMovementMethod
Subclasses override this to specify a default movement method. -
getMovementMethod
Gets theMovementMethodbeing used for this TextView, which provides positioning, scrolling, and text selection functionality. This will frequently be null for non-editable TextViews.- Returns:
- the movement method being used for this TextView.
- See Also:
-
setMovementMethod
Sets theMovementMethodfor handling arrow key movement for this TextView. This can be null to disallow using the arrow keys to move the cursor or scroll the view.Be warned that if you want a TextView with a movement method not to be focusable, or if you want a TextView without a 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.- Parameters:
movement- the movement method to set
-
getTransformationMethod
Gets the currentTransformationMethodfor the TextView. This is frequently null, except for single-line and password fields.- Returns:
- the current transformation method for this TextView.
-
setTransformationMethod
Sets the transformation that is applied to the text that this TextView is displaying.- Parameters:
method- the transformation method to set
-
getCompoundPaddingTop
public int getCompoundPaddingTop()Returns the top padding of the view, plus space for the top Drawable if any. -
getCompoundPaddingBottom
public int getCompoundPaddingBottom()Returns the bottom padding of the view, plus space for the bottom Drawable if any. -
getCompoundPaddingLeft
public int getCompoundPaddingLeft()Returns the left padding of the view, plus space for the left Drawable if any. -
getCompoundPaddingRight
public int getCompoundPaddingRight()Returns the right padding of the view, plus space for the right Drawable if any. -
getCompoundPaddingStart
public int getCompoundPaddingStart()Returns the start padding of the view, plus space for the start Drawable if any. -
getCompoundPaddingEnd
public int getCompoundPaddingEnd()Returns the end padding of the view, plus space for the end Drawable if any. -
getExtendedPaddingTop
public 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. It is only valid to call this after measuring. -
getExtendedPaddingBottom
public 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. It is only valid to call this after measuring. -
getTotalPaddingLeft
public int getTotalPaddingLeft()Returns the total left padding of the view, including the left Drawable if any. -
getTotalPaddingRight
public int getTotalPaddingRight()Returns the total right padding of the view, including the right Drawable if any. -
getTotalPaddingStart
public int getTotalPaddingStart()Returns the total start padding of the view, including the start Drawable if any. -
getTotalPaddingEnd
public int getTotalPaddingEnd()Returns the total end padding of the view, including the end Drawable if any. -
getTotalPaddingTop
public 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. -
getTotalPaddingBottom
public 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. -
setCompoundDrawables
public void setCompoundDrawables(@Nullable Drawable left, @Nullable Drawable top, @Nullable Drawable right, @Nullable Drawable bottom) Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Usenullif you do not want a Drawable there. The Drawables must already have hadDrawable.setBounds(int, int, int, int)called.Calling this method will overwrite any Drawables previously set using
setCompoundDrawablesRelative(icyllis.modernui.graphics.drawable.Drawable, icyllis.modernui.graphics.drawable.Drawable, icyllis.modernui.graphics.drawable.Drawable, icyllis.modernui.graphics.drawable.Drawable)or related methods. -
setCompoundDrawablesWithIntrinsicBounds
public void setCompoundDrawablesWithIntrinsicBounds(@Nullable Drawable left, @Nullable Drawable top, @Nullable Drawable right, @Nullable Drawable bottom) Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Usenullif you do not want a Drawable there. The Drawables' bounds will be set to their intrinsic bounds.Calling this method will overwrite any Drawables previously set using
setCompoundDrawablesRelative(icyllis.modernui.graphics.drawable.Drawable, icyllis.modernui.graphics.drawable.Drawable, icyllis.modernui.graphics.drawable.Drawable, icyllis.modernui.graphics.drawable.Drawable)or related methods. -
setCompoundDrawablesRelative
public void setCompoundDrawablesRelative(@Nullable Drawable start, @Nullable Drawable top, @Nullable Drawable end, @Nullable Drawable bottom) Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text. Usenullif you do not want a Drawable there. The Drawables must already have hadDrawable.setBounds(int, int, int, int)called.Calling this method will overwrite any Drawables previously set using
setCompoundDrawables(icyllis.modernui.graphics.drawable.Drawable, icyllis.modernui.graphics.drawable.Drawable, icyllis.modernui.graphics.drawable.Drawable, icyllis.modernui.graphics.drawable.Drawable)or related methods. -
setCompoundDrawablesRelativeWithIntrinsicBounds
public void setCompoundDrawablesRelativeWithIntrinsicBounds(@Nullable Drawable start, @Nullable Drawable top, @Nullable Drawable end, @Nullable Drawable bottom) Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text. Usenullif you do not want a Drawable there. The Drawables' bounds will be set to their intrinsic bounds.Calling this method will overwrite any Drawables previously set using
setCompoundDrawables(icyllis.modernui.graphics.drawable.Drawable, icyllis.modernui.graphics.drawable.Drawable, icyllis.modernui.graphics.drawable.Drawable, icyllis.modernui.graphics.drawable.Drawable)or related methods. -
getCompoundDrawables
Returns drawables for the left, top, right, and bottom borders. -
getCompoundDrawablesRelative
Returns drawables for the start, top, end, and bottom borders. -
setCompoundDrawablePadding
public void setCompoundDrawablePadding(int pad) Sets the size of the padding between the compound drawables and the text. -
getCompoundDrawablePadding
public int getCompoundDrawablePadding()Returns the padding between the compound drawables and the text. -
setCompoundDrawableTintList
Applies a tint to the compound drawables. Does not modify the current tint mode, which isBlendMode.SRC_INby default.Subsequent calls to
setCompoundDrawables(Drawable, Drawable, Drawable, Drawable)and related methods will automatically mutate the drawables and apply the specified tint and tint mode usingDrawable.setTintList(ColorStateList).- Parameters:
tint- the tint to apply, may benullto clear tint- See Also:
-
getCompoundDrawableTintList
- Returns:
- the tint applied to the compound drawables
- See Also:
-
setCompoundDrawableTintBlendMode
Specifies the blending mode used to apply the tint specified bysetCompoundDrawableTintList(ColorStateList)to the compound drawables. The default mode isBlendMode.SRC_IN.- Parameters:
blendMode- the blending mode used to apply the tint, may benullto clear tint- See Also:
-
getCompoundDrawableTintBlendMode
Returns the blending mode used to apply the tint to the compound drawables, if specified.- Returns:
- the blending mode used to apply the tint to the compound drawables
- See Also:
-
setPadding
public void setPadding(int left, int top, int right, int bottom) Description copied from class:ViewSets the padding. The view may add on the space required to display the scrollbars, depending on the style and visibility of the scrollbars. So the values returned fromView.getPaddingLeft(),View.getPaddingTop(),View.getPaddingRight()andView.getPaddingBottom()may be different from the values set in this call.- Overrides:
setPaddingin classView- Parameters:
left- the left padding in pixelstop- the top padding in pixelsright- the right padding in pixelsbottom- the bottom padding in pixels
-
setPaddingRelative
public void setPaddingRelative(int start, int top, int end, int bottom) Description copied from class:ViewSets the relative padding. The view may add on the space required to display the scrollbars, depending on the style and visibility of the scrollbars. So the values returned fromView.getPaddingStart(),View.getPaddingTop(),View.getPaddingEnd()andView.getPaddingBottom()may be different from the values set in this call.- Overrides:
setPaddingRelativein classView- Parameters:
start- the start padding in pixelstop- the top padding in pixelsend- the end padding in pixelsbottom- the bottom padding in pixels
-
setFirstBaselineToTopHeight
public void setFirstBaselineToTopHeight(int firstBaselineToTopHeight) Updates the top padding of the TextView so thatfirstBaselineToTopHeightis the distance between the top of the TextView and first line's baseline. Note that ifFontMetrics.toporFontMetrics.ascentwas already greater thanfirstBaselineToTopHeight, the top padding is not updated. Moreover, since this function sets the top padding, if the height of the TextView is less than the sum of top padding, line height and bottom padding, top of the line will be pushed down and bottom will be clipped.- Parameters:
firstBaselineToTopHeight- distance between first baseline to top of the container in pixels- See Also:
-
setLastBaselineToBottomHeight
public void setLastBaselineToBottomHeight(int lastBaselineToBottomHeight) Updates the bottom padding of the TextView so thatlastBaselineToBottomHeightis the distance between the bottom of the TextView and the last line's baseline. Note that ifFontMetrics.bottomorFontMetrics.descentwas already greater thanlastBaselineToBottomHeight, the bottom padding is not updated. Moreover, since this function sets the bottom padding, if the height of the TextView is less than the sum of top padding, line height and bottom padding, bottom of the text will be clipped.- Parameters:
lastBaselineToBottomHeight- distance between last baseline to bottom of the container in pixels- See Also:
-
getFirstBaselineToTopHeight
public int getFirstBaselineToTopHeight()Returns the distance between the first text baseline and the top of this TextView.- See Also:
-
getLastBaselineToBottomHeight
public int getLastBaselineToBottomHeight()Returns the distance between the last text baseline and the bottom of this TextView.- See Also:
-
setTextAppearance
Sets the text appearance from the specified style resource.Use a framework-defined
TextAppearancestyle like@modernui:style/TextAppearance.Material3.BodyMediumor seeTextAppearancefor the set of attributes that can be used in a custom style.- Parameters:
resId- the resource identifier of the style to apply
-
setTextAppearance
public void setTextAppearance(icyllis.modernui.resources.TextAppearance textAppearance) Sets the text appearance. The non-default attribute values in TextAppearance will be applied to this TextView.- Parameters:
textAppearance- the text appearance to apply
-
getTextLocale
Get the default primaryLocaleof the text in this TextView.- Returns:
- the default primary
Localeof the text in this TextView.
-
setTextLocale
Set the defaultLocaleof the text in this TextView to the given Locale.- Parameters:
locale- theLocalefor drawing text, must not be null.
-
getTextSize
public float getTextSize()- Returns:
- the size (in pixels) of the default text size in this TextView.
-
setTextSize
public void setTextSize(float size) Set the default text size to the given value, interpreted as "scaled pixel" units. This size is adjusted based on the current density and user font size preference.- Parameters:
size- The scaled pixel size.
-
setTextSize
public void setTextSize(int unit, float size) Set the default text size to a given unit and value. SeeTypedValuefor the possible dimension units.- Parameters:
unit- The desired dimension unit.size- The desired size in the given units.
-
getTextSizeUnit
public int getTextSizeUnit()Gets the text size unit defined by the developer. It may be specified in resources or be passed as the unit argument ofsetTextSize(int, float)at runtime.- Returns:
- the dimension type of the text size unit originally defined.
- See Also:
-
setTextStyle
public void setTextStyle(int style) Sets the default text style in which the text should be displayed.- Parameters:
style- the text style to set- See Also:
-
getTextStyle
public int getTextStyle()Gets the current text style that is used to style the text.- Returns:
- the current text style
- See Also:
-
setTypeface
Sets the typeface in which the text should be displayed.- See Also:
-
getTypeface
Gets the currentTypefacethat is used to style the text.- Returns:
- The current Typeface.
- See Also:
-
getLineHeight
public int getLineHeight()Gets the vertical distance between lines of text, in pixels. Note that markup within the text can cause individual lines to be taller or shorter than this height, and the layout may contain additional first-or last-line padding.- Returns:
- The height of one standard line in pixels.
-
setFallbackLineSpacing
public void setFallbackLineSpacing(boolean enabled) Set whether to respect the ascent and descent of the fallback fonts that are used in displaying the text (which is needed to avoid text from consecutive lines running into each other). If set, fallback fonts that end up getting used can increase the ascent and descent of the lines that they are used on. It is required to be true if text could be in languages like Burmese or Tibetan where text is typically much taller or deeper than Latin text.- Parameters:
enabled- whether to expand line spacing based on fallback fonts,trueby default- See Also:
-
isFallbackLineSpacing
public boolean isFallbackLineSpacing()- Returns:
- whether fallback line spacing is enabled,
trueby default - See Also:
-
setLineBreakStyle
public void setLineBreakStyle(int lineBreakStyle) Set the line break style for text wrapping.The line break style to indicates the line break strategies can be used when calculating the text wrapping. The line break style affects rule-based breaking. It specifies the strictness of line-breaking rules. There are several types for the line break style:
LineBreakConfig.LINE_BREAK_STYLE_LOOSE,LineBreakConfig.LINE_BREAK_STYLE_NORMALandLineBreakConfig.LINE_BREAK_STYLE_STRICT. The default values of the line break style isLineBreakConfig.LINE_BREAK_STYLE_NONE, indicating no breaking rule is specified. See the line-break property- Parameters:
lineBreakStyle- the line break style for the text.
-
setLineBreakWordStyle
public void setLineBreakWordStyle(int lineBreakWordStyle) Set the line break word style for text wrapping.The line break word style affects dictionary-based breaking and provide phrase-based breaking opportunities. The type for the line break word style is
LineBreakConfig.LINE_BREAK_WORD_STYLE_PHRASE. The default values of the line break word style isLineBreakConfig.LINE_BREAK_WORD_STYLE_NONE, indicating no breaking rule is specified. See the word-break property- Parameters:
lineBreakWordStyle- the line break word style for the tet
-
getLineBreakStyle
public int getLineBreakStyle()Get the current line break style for text wrapping.- Returns:
- the current line break style to be used for text wrapping.
-
getLineBreakWordStyle
public int getLineBreakWordStyle()Get the current line word break style for text wrapping.- Returns:
- the current line break word style to be used for text wrapping.
-
getTextMetricsParams
Gets the parameters for text layout pre-computation, for use withPrecomputedText.- Returns:
- a current
PrecomputedText.Params - See Also:
-
setTextMetricsParams
Apply the text layout parameter.Update the TextView parameters to be compatible with
PrecomputedText.Params.- See Also:
-
setTextColor
public void setTextColor(int color) Sets the text color for all the states (normal, selected, focused) to be this color.- Parameters:
color- A color value in the form 0xAARRGGBB.- See Also:
-
setTextColor
Sets the text color.- See Also:
-
getTextColors
Gets the text colors for the different states (normal, selected, focused) of the TextView.- See Also:
-
getCurrentTextColor
public final int getCurrentTextColor()Return the current color selected for normal text.- Returns:
- Returns the current text color.
-
setHighlightColor
public void setHighlightColor(int color) Sets the color used to display the selection highlight. -
getHighlightColor
public int getHighlightColor()- Returns:
- the color used to display the selection highlight
- See Also:
-
getPaint
Gets theTextPaintused for the text. Use this only to consult the Paint's properties and not to change them.- Returns:
- The base paint used for the text.
-
getLayout
Gets theLayoutthat is currently being used to display the text. This value can be null if the text or width has recently changed.- Returns:
- The Layout that is currently being used to display the text.
-
setAutoLinkMask
public final void setAutoLinkMask(int mask) Sets the autolink mask of the text. -
getAutoLinkMask
public final int getAutoLinkMask()Gets the autolink mask of the text. -
setLinksClickable
public final void setLinksClickable(boolean whether) Sets whether the movement method will automatically be set toLinkMovementMethodifsetAutoLinkMask(int)has been set to nonzero and links are detected insetText(java.lang.CharSequence). The default is true. -
getLinksClickable
public final boolean getLinksClickable()Returns whether the movement method will automatically be set toLinkMovementMethodifsetAutoLinkMask(int)has been set to nonzero and links are detected insetText(java.lang.CharSequence). The default is true. -
setHintTextColor
public final void setHintTextColor(int color) Sets the color of the hint text for all the states (disabled, focussed, selected...) of this TextView.- See Also:
-
setHintTextColor
Sets the color of the hint text.- See Also:
-
getHintTextColors
- Returns:
- the color of the hint text, for the different states of this TextView.
- See Also:
-
getCurrentHintTextColor
public final int getCurrentHintTextColor()Return the current color selected to paint the hint text.
- Returns:
- Returns the current hint text color.
-
setLinkTextColor
public final void setLinkTextColor(int color) Sets the color of links in the text.- See Also:
-
setLinkTextColor
Sets the color of links in the text.- See Also:
-
getLinkTextColors
- Returns:
- the list of colors used to paint the links in the text, for the different states of this TextView
- See Also:
-
setGravity
public 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.- See Also:
-
getGravity
public int getGravity()Returns the horizontal and vertical alignment of this TextView.- See Also:
-
setHorizontallyScrolling
public void setHorizontallyScrolling(boolean whether) Sets whether the text should be allowed to be wider than the View is. If false, it will be wrapped to the width of the View. -
isHorizontallyScrollable
public final boolean isHorizontallyScrollable()Returns whether the text is allowed to be wider than the View. If false, the text will be wrapped to the width of the View.- See Also:
-
setMinLines
public void setMinLines(int minLines) Sets the height of the TextView to be at leastminLinestall.This value is used for height calculation if LayoutParams does not force TextView to have an exact height. Setting this value overrides other previous minimum height configurations such as
setMinHeight(int)orsetHeight(int).setSingleLine()will set this value to 1.- Parameters:
minLines- the minimum height of TextView in terms of number of lines- See Also:
-
getMinLines
public int getMinLines()Returns the minimum height of TextView in terms of number of lines or -1 if the minimum height was set usingsetMinHeight(int)orsetHeight(int).- Returns:
- the minimum height of TextView in terms of number of lines or -1 if the minimum height is not defined in lines
- See Also:
-
setMinHeight
public void setMinHeight(int minPixels) Sets the height of the TextView to be at leastminPixelstall.This value is used for height calculation if LayoutParams does not force TextView to have an exact height. Setting this value overrides previous minimum height configurations such as
setMinLines(int)orsetLines(int).The value given here is different than
View.setMinimumHeight(int). BetweenminHeightand the value set inView.setMinimumHeight(int), the greater one is used to decide the final height.- Parameters:
minPixels- the minimum height of TextView in terms of pixels- See Also:
-
getMinHeight
public int getMinHeight()Returns the minimum height of TextView in terms of pixels or -1 if the minimum height was set usingsetMinLines(int)orsetLines(int).- Returns:
- the minimum height of TextView in terms of pixels or -1 if the minimum height is not defined in pixels
- See Also:
-
setMaxLines
public void setMaxLines(int maxLines) Sets the height of the TextView to be at mostmaxLinestall.This value is used for height calculation if LayoutParams does not force TextView to have an exact height. Setting this value overrides previous maximum height configurations such as
setMaxHeight(int)orsetLines(int).- Parameters:
maxLines- the maximum height of TextView in terms of number of lines- See Also:
-
getMaxLines
public int getMaxLines()Returns the maximum height of TextView in terms of number of lines or -1 if the maximum height was set usingsetMaxHeight(int)orsetHeight(int).- Returns:
- the maximum height of TextView in terms of number of lines. -1 if the maximum height is not defined in lines.
- See Also:
-
setMaxHeight
public void setMaxHeight(int maxPixels) Sets the height of the TextView to be at mostmaxPixelstall.This value is used for height calculation if LayoutParams does not force TextView to have an exact height. Setting this value overrides previous maximum height configurations such as
setMaxLines(int)orsetLines(int).- Parameters:
maxPixels- the maximum height of TextView in terms of pixels- See Also:
-
getMaxHeight
public int getMaxHeight()Returns the maximum height of TextView in terms of pixels or -1 if the maximum height was set usingsetMaxLines(int)orsetLines(int).- Returns:
- the maximum height of TextView in terms of pixels or -1 if the maximum height is not defined in pixels
- See Also:
-
setLines
public void setLines(int lines) Sets the height of the TextView to be exactlylinestall.This value is used for height calculation if LayoutParams does not force TextView to have an exact height. Setting this value overrides previous minimum/maximum height configurations such as
setMinLines(int)orsetMaxLines(int).setSingleLine()will set this value to 1.- Parameters:
lines- the exact height of the TextView in terms of lines- See Also:
-
setHeight
public void setHeight(int pixels) Sets the height of the TextView to be exactlypixelstall.This value is used for height calculation if LayoutParams does not force TextView to have an exact height. Setting this value overrides previous minimum/maximum height configurations such as
setMinHeight(int)orsetMaxHeight(int).- Parameters:
pixels- the exact height of the TextView in terms of pixels- See Also:
-
setMinWidth
public void setMinWidth(int minPixels) Sets the width of the TextView to be at leastminPixelswide.This value is used for width calculation if LayoutParams does not force TextView to have an exact width.
The value given here is different from
View.setMinimumWidth(int). BetweenminWidthand the value set inView.setMinimumWidth(int), the greater one is used to decide the final width.- Parameters:
minPixels- the minimum width of TextView in terms of pixels- See Also:
-
getMinWidth
public int getMinWidth()Returns the minimum width of TextView in terms of pixels.- Returns:
- the minimum width of TextView in terms of pixels.
- See Also:
-
setMaxWidth
public void setMaxWidth(int maxPixels) Sets the width of the TextView to be at mostmaxPixelswide.This value is used for width calculation if LayoutParams does not force TextView to have an exact width.
- Parameters:
maxPixels- the maximum width of TextView in terms of pixels- See Also:
-
getMaxWidth
public int getMaxWidth()Returns the maximum width of TextView in terms of pixels.- Returns:
- the maximum width of TextView in terms of pixels.
- See Also:
-
setWidth
public void setWidth(int pixels) Sets the width of the TextView to be exactlypixelswide.This value is used for width calculation if LayoutParams does not force TextView to have an exact width. Setting this value overrides previous minimum/maximum width configurations such as
setMinWidth(int)orsetMaxWidth(int).- Parameters:
pixels- the exact width of the TextView in terms of pixels
-
setLineSpacing
public void setLineSpacing(float add, float mult) Sets line spacing for this TextView. Each line other than the last line will have its height multiplied bymultand haveaddadded to it.- Parameters:
add- The value in pixels that should be added to each line other than the last line. This will be applied after the multipliermult- The value by which each line height other than the last line will be multiplied by
-
getLineSpacingMultiplier
public float getLineSpacingMultiplier()Returns the multiplier applied to the line height.- Returns:
- the value by which each line's height is multiplied to get its actual height.
- See Also:
-
getLineSpacingAmount
public float getLineSpacingAmount()Returns the amount added to the line height.- Returns:
- the extra space that is added to the height of each lines of this TextView.
- See Also:
-
setLineHeight
Sets an explicit line height for this TextView. This is equivalent to the vertical distance between subsequent baselines in the TextView.- Parameters:
lineHeight- the line height in pixels- See Also:
-
setLineHeight
Sets an explicit line height to a given unit and value for this TextView. This is equivalent to the vertical distance between subsequent baselines in the TextView. SeeTypedValuefor the possible dimension units.- Parameters:
unit- The desired dimension unit. SP units are strongly recommended so that line height stays proportional to the text size when fonts are scaled up for accessibility.lineHeight- The desired line height in the given units.- See Also:
-
getText
Return the text that TextView is displaying. IfsetText(CharSequence)was called with an argument ofBufferType.SPANNABLEorBufferType.EDITABLE, you can cast the return value from this method to Spannable or Editable, respectively.The content of the return value should not be modified. If you want a modifiable one, you should make your own copy first.
- Returns:
- The text displayed by the text view.
-
getEditableText
Return the text that TextView is displaying as an Editable object. If the text is not editable, null is returned.- See Also:
-
setEditableFactory
Sets the Factory used to create newEditables.- Parameters:
factory-Editable.Factoryto be used- See Also:
-
setSpannableFactory
Sets the Factory used to create newSpannables.- Parameters:
factory-Spannable.Factoryto be used- See Also:
-
setText
Sets the text to be displayed. To style your strings, attachCharacterStyleto aSpannableString.When required, TextView will use
Spannable.Factoryto create final or intermediateSpannables. Likewise, it will useEditable.Factoryto create final or intermediateEditables.If the passed text is a
PrecomputedTextbut the parameters used to create the PrecomputedText mismatches with this TextView, IllegalArgumentException is thrown.- Parameters:
text- text to be displayed- Throws:
IllegalArgumentException- if the passed text is aPrecomputedTextbut the parameters used to create the PrecomputedText mismatches with this TextView.
-
setTextKeepState
Sets the text to be displayed but retains the cursor position. Same assetText(CharSequence)except that the cursor position (if any) is retained in the new text. When required, TextView will useSpannable.Factoryto create final or intermediateSpannables. Likewise, it will useEditable.Factoryto create final or intermediateEditables.- Parameters:
text- text to be displayed- See Also:
-
setTextKeepState
Sets the text to be displayed and theTextView.BufferTypebut retains the cursor position. Same assetText(CharSequence, BufferType)except that the cursor position (if any) is retained in the new text. When required, TextView will useSpannable.Factoryto create final or intermediateSpannables. Likewise, it will useEditable.Factoryto create final or intermediateEditables.- Parameters:
text- text to be displayedtype- aTextView.BufferTypewhich defines whether the text is stored as a static text, styleable/spannable text, or editable text- See Also:
-
setText
Sets the text to be displayed and theTextView.BufferType. When required, TextView will useSpannable.Factoryto create final or intermediateSpannables. Likewise, it will useEditable.Factoryto create final or intermediateEditables.Subclasses overriding this method should ensure that the following post condition holds, in order to guarantee the safety of the view's measurement and layout operations: regardless of the input, after calling #setText both
mTextandmTransformedwill be different fromnull.- Parameters:
text- text to be displayedtype- aTextView.BufferTypewhich defines whether the text is stored as a static text, styleable/spannable text, or editable text- See Also:
-
getHint
Returns the hint that is displayed when the text of the TextView is empty. -
setHint
Sets the text to be displayed when the text of the TextView is empty. Null means to use the normal empty text. The hint does not currently participate in determining the size of the view. -
setFilters
Sets the list of input filters that will be used if the buffer is Editable. Has no effect otherwise. -
getFilters
Returns the current list of input filters. -
onPreDraw
public boolean onPreDraw()Callback method to be invoked when the view tree is about to be drawn. At this point, all views in the tree have been measured and given a frame. Clients can use this to adjust their scroll bounds or even to request a new layout before drawing occurs.- Specified by:
onPreDrawin interfaceViewTreeObserver.OnPreDrawListener- Returns:
- Return true to proceed with the current drawing pass, or false to cancel.
- See Also:
-
onAttachedToWindow
protected void onAttachedToWindow()Description copied from class:ViewThis is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called beforeView.onDraw(Canvas), however it may be called any time before the first onDraw -- including before or afterView.onMeasure(int, int).- Overrides:
onAttachedToWindowin classView- See Also:
-
onDetachedFromWindow
protected void onDetachedFromWindow()Description copied from class:ViewThis is called when the view is detached from a window. At this point it no longer has a surface for drawing.- Overrides:
onDetachedFromWindowin classView- See Also:
-
verifyDrawable
Description copied from class:ViewIf your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying. This allows animations for those drawables to be scheduled.Be sure to call through to the super class when overriding this function.
- Overrides:
verifyDrawablein classView- Parameters:
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.- Returns:
- boolean If true then the Drawable is being displayed in the view; else false and it is not allowed to animate.
- See Also:
-
jumpDrawablesToCurrentState
public void jumpDrawablesToCurrentState()Description copied from class:ViewCallDrawable.jumpToCurrentState()on all Drawable objects associated with this view.Also calls
StateListAnimator.jumpToCurrentState()if there is a StateListAnimator attached to this view.- Overrides:
jumpDrawablesToCurrentStatein classView
-
invalidateDrawable
Description copied from class:ViewInvalidates the specified Drawable.- Specified by:
invalidateDrawablein interfaceDrawable.Callback- Overrides:
invalidateDrawablein classView- Parameters:
drawable- the drawable to invalidate
-
isTextSelectable
public boolean isTextSelectable()Returns the state of thetextIsSelectableflag (SeesetTextIsSelectable()). Although you have to set this flag to allow users to select and copy text in a non-editable TextView, the content of an EditText can always be selected, independently of the value of this flag.- Returns:
- True if the text displayed in this TextView can be selected by the user.
-
setTextIsSelectable
public void setTextIsSelectable(boolean selectable) Sets whether the content of this view is selectable by the user. The default isfalse, meaning that the content is not selectable.When you use a TextView to display a useful piece of information to the user (such as a contact's address), make it selectable, so that the user can select and copy its content.
When you call this method to set the value of
textIsSelectable, it sets the flagsfocusable,focusableInTouchMode,clickable, andlongClickableto the same value. To restore any of these flags to a state you had set previously, call one or more of the following methods:setFocusable(),setFocusableInTouchMode(),setClickable()orsetLongClickable().The content of an EditText (A editable TextView) can always be selected, and you should not the value of this flag.
- Parameters:
selectable- Whether the content of this TextView should be selectable.
-
drawableStateChanged
protected void drawableStateChanged()Description copied from class:ViewThis function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.If the View has a StateListAnimator, it will also be called to run necessary state change animations.
Be sure to call through to the superclass when overriding this function.
- Overrides:
drawableStateChangedin classView- See Also:
-
drawableHotspotChanged
public void drawableHotspotChanged(float x, float y) Description copied from class:ViewThis function is called whenever the view hotspot changes and needs to be propagated to drawables or child views managed by the view.Dispatching to child views is handled by
View.dispatchDrawableHotspotChanged(float, float).Be sure to call through to the superclass when overriding this function.
- Overrides:
drawableHotspotChangedin classView- Parameters:
x- hotspot x coordinatey- hotspot y coordinate
-
onCreateDrawableState
Description copied from class:ViewGenerate the newDrawablestate 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 useView.getDrawableState().- Overrides:
onCreateDrawableStatein classView- Parameters:
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.- Returns:
- an array holding the current
Drawablestate of the view. - See Also:
-
onDraw
Description copied from class:ViewDraw the content of this view, implement this to do your drawing.Note that (0, 0) will be the top left of the bounds, and (width, height) will be the bottom right of the bounds.
-
getFocusedRect
Description copied from class:ViewWhen 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.By default, the rectangle is the
View.getDrawingRect(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.- Overrides:
getFocusedRectin classView- Parameters:
r- The rectangle to fill in, in this view's coordinates.
-
getLineCount
public int getLineCount()Return the number of lines of text, or 0 if the internal Layout has not been built. -
getLineBounds
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. If the internal Layout has not been built, return 0 and set bounds to (0, 0, 0, 0)- Parameters:
line- which line to examine (0..getLineCount() - 1)bounds- Optional. If not null, it returns the extent of the line- Returns:
- the Y-coordinate of the baseline
-
getBaseline
public int getBaseline()Description copied from class:ViewReturn 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.
- Overrides:
getBaselinein classView- Returns:
- the offset of the baseline within the widget's bounds or -1 if baseline alignment is not supported
-
makeNewLayout
@VisibleForTesting public final 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. -
setIncludeFontPadding
public 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. The default is true.- See Also:
-
getIncludeFontPadding
public 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.- See Also:
-
onMeasure
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) Description copied from class:ViewMeasure the view and its content to determine the measured width and the measured height. This method is invoked byView.measure(int, int)and should be overridden 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 anIllegalStateException, thrown byView.measure(int, int). Calling super.onMeasure() 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 the base one to provide better measurements of their content.
- Overrides:
onMeasurein classView- Parameters:
widthMeasureSpec- width measure specification imposed by the parentMeasureSpecheightMeasureSpec- height measure specification imposed by the parentMeasureSpec
-
onLayout
protected void onLayout(boolean changed, int left, int top, int right, int bottom) Description copied from class:ViewCalled fromView.layout(int, int, int, int)when this view should assign a size and position to each of its children.Derived classes with children should override this method and call layout on each of their children.
-
bringPointIntoView
public boolean bringPointIntoView(int offset) Move the point, specified by the offset, into the view if it is needed. This has to be called after layout. Returns true if anything changed. -
moveCursorToVisibleOffset
public boolean moveCursorToVisibleOffset()Move the cursor, if needed, so that it is at an offset that is visible to the user. This will not move the cursor if it represents more than one character (a selection range). This will only work if the TextView contains spannable text; otherwise it will do nothing.- Returns:
- True if the cursor was actually moved, false otherwise.
-
getSelectionStart
public int getSelectionStart()Convenience forSelection.getSelectionStart(java.lang.CharSequence). -
getSelectionEnd
public int getSelectionEnd()Convenience forSelection.getSelectionEnd(java.lang.CharSequence). -
hasSelection
public boolean hasSelection()Return true iff there is a selection of nonzero length inside this text view. -
setSingleLine
public void setSingleLine()Sets the properties of this field (lines, horizontally scrolling, transformation method) to be for a single-line input. -
setSingleLine
public 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.Note that the default conditions are not necessarily those that were in effect prior this method, and you may want to reset these properties to your custom values.
Note that due to performance reasons, by setting single line for the EditText, the maximum text length is set to 5000 if no other character limitation are applied.
-
setEllipsize
Causes words in the text that are longer than the view's width to be ellipsized instead of broken in the middle. You may also want tosetSingleLine()orsetHorizontallyScrolling(boolean)to constrain the text to a single line. Usenullto turn off ellipsizing.If
setMaxLines(int)has been used to set two or more lines, onlyTextUtils.TruncateAt.ENDis supported (other ellipsizing types will not do anything). -
getEllipsize
Returns where, if anywhere, words that are longer than the view is wide should be ellipsized. -
setSelectAllOnFocus
public void setSelectAllOnFocus(boolean selectAllOnFocus) Set the TextView so that when it takes focus, all the text is selected. -
setCursorVisible
public void setCursorVisible(boolean visible) Set whether the cursor is visible. The default is true. Note that this property only makes sense for editable TextView. If IME is consuming the input, the cursor will always be invisible, visibility will be updated as the last state when IME does not consume the input anymore.- See Also:
-
isCursorVisible
public boolean isCursorVisible()- Returns:
- whether the cursor is visible (assuming this TextView is editable). This
method may return
falsewhen the IME is consuming the input even if themEditor.mCursorVisibleattribute istrueor#setCursorVisible(true)is called. - See Also:
-
onTextChanged
This method is called when the text is changed, in case any subclasses would like to know.Within
text, thelengthAftercharacters beginning atstarthave just replaced old text that had lengthlengthBefore. It is an error to attempt to make changes totextfrom this callback.- Parameters:
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 text
-
addTextChangedListener
Adds a TextWatcher to the list of those whose methods are called whenever this TextView's text changes.In 1.0, the
TextWatcher.afterTextChanged(icyllis.modernui.text.Editable)method was erroneously not called aftersetText(java.lang.CharSequence)calls. Now, doingsetText(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.- Parameters:
watcher- the watcher to add
-
removeTextChangedListener
Removes the specified TextWatcher from the list of those whose methods are called whenever this TextView's text changes.- Parameters:
watcher- the watcher to remove
-
onFocusChanged
Description copied from class:ViewCalled by the view system when the focus state of this view changes. When the focus change event is caused by directional navigation, direction and previouslyFocusedRect provide insight into where the focus is coming from. When overriding, be sure to call up through to the super class so that the standard focus handling will occur.- Overrides:
onFocusChangedin classView- Parameters:
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 areView.FOCUS_UP,View.FOCUS_DOWN,View.FOCUS_LEFT,View.FOCUS_RIGHT,View.FOCUS_FORWARD, orView.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 benullotherwise.
-
onTouchEvent
Description copied from class:ViewImplement this method to handle touch screen motion events.If this method is used to detect click actions, it is recommended that the actions be performed by implementing and calling
View.performClick(). This will ensure consistent system behavior.- Overrides:
onTouchEventin classView- Parameters:
event- the touch event- Returns:
trueif the event was handled by the view,falseotherwise
-
onGenericMotionEvent
Description copied from class:ViewImplement this method to handle generic motion events.Implementations of this method should check if this view ENABLED and CLICKABLE.
- Overrides:
onGenericMotionEventin classView- Parameters:
event- the generic motion event being processed.- Returns:
trueif the event was consumed by the view,falseotherwise
-
onCreateContextMenu
Description copied from class:ViewViews should implement this if the view itself is going to add items to the context menu.- Overrides:
onCreateContextMenuin classView- Parameters:
menu- the context menu to populate
-
showContextMenu
public boolean showContextMenu(float x, float y) Description copied from class:ViewShows the context menu for this view anchored to the specified view-relative coordinate.- Overrides:
showContextMenuin classView- Parameters:
x- the X coordinate in pixels relative to the view to which the menu should be anchored, orFloat.NaNto disable anchoringy- the Y coordinate in pixels relative to the view to which the menu should be anchored, orFloat.NaNto disable anchoring- Returns:
trueif the context menu was shown,falseotherwise
-
didTouchFocusSelect
public 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. Only valid while processing the touch gesture of interest, in an editable text view. -
cancelLongPress
public void cancelLongPress()Description copied from class:ViewCancels a pending long press. Your subclass can use this if you want the context menu to come up if the user presses and holds at the same place, but you don't want it to come up if they press and then move around enough to cause scrolling.- Overrides:
cancelLongPressin classView
-
computeHorizontalScrollRange
protected int computeHorizontalScrollRange()Description copied from class:ViewCompute 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()andView.computeHorizontalScrollOffset().The default range is the drawing width of this view.
- Overrides:
computeHorizontalScrollRangein classView- Returns:
- the total horizontal range represented by the horizontal scrollbar
- See Also:
-
computeVerticalScrollRange
protected int computeVerticalScrollRange()Description copied from class:ViewCompute 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()andView.computeVerticalScrollOffset().- Overrides:
computeVerticalScrollRangein classView- Returns:
- the total vertical range represented by the vertical scrollbar
The default range is the drawing height of this view.
- See Also:
-
computeVerticalScrollExtent
protected int computeVerticalScrollExtent()Description copied from class:ViewCompute the vertical extent of the vertical 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()andView.computeVerticalScrollOffset().The default extent is the drawing height of this view.
- Overrides:
computeVerticalScrollExtentin classView- Returns:
- the vertical extent of the scrollbar's thumb
- See Also:
-
onKeyDown
Description copied from class:ViewDefault implementation: perform press of the view whenKeyEvent.KEY_ENTER,KeyEvent.KEY_KP_ENTERorKeyEvent.KEY_SPACEis released, if the view is enabled and clickable. -
onKeyUp
Description copied from class:ViewDefault implementation: perform clicking of the view whenKeyEvent.KEY_ENTER,KeyEvent.KEY_KP_ENTERorKeyEvent.KEY_SPACEis released. -
onKeyShortcut
Description copied from class:ViewCalled on the focused view when a key shortcut event is not handled. Override this method to implement local key shortcuts for the View. Key shortcuts can also be implemented by setting theshortcutproperty of menu items.- Overrides:
onKeyShortcutin classView- Parameters:
keyCode- The value in event.getKeyCode().event- Description of the key event.- Returns:
- If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.
-
onTextContextMenuItem
public boolean onTextContextMenuItem(int id) Called when a context menu option for the text view is selected. Currently, this will be one ofR.id.selectAll,R.id.cut,R.id.copy,R.id.paste.- Returns:
- true if the context menu item action was performed.
-
onRtlPropertiesChanged
protected void onRtlPropertiesChanged(int layoutDirection) Description copied from class:ViewCalled when any RTL property (layout direction or text direction or text alignment) has been changed.Subclasses need to override this method to take care of cached information that depends on the resolved layout direction, or to inform child views that inherit their layout direction.
The default implementation does nothing.
- Overrides:
onRtlPropertiesChangedin classView- Parameters:
layoutDirection- the direction of the layout- See Also:
-
getTextDirectionHeuristic
Returns resolvedTextDirectionHeuristicthat will be used for text layout. TheTextDirectionHeuristicthat is used by TextView is only available afterView.getTextDirection()andView.getLayoutDirection()is resolved. Therefore the return value may not be the same as the one TextView uses if the View's layout direction is not resolved or detached from parent root view. -
onResolvePointerIcon
Description copied from class:ViewReturns the pointer icon for the motion event, or null if it doesn't specify the icon. The default implementation does not care the location or event types, but some subclasses may use it (such as WebViews).- Overrides:
onResolvePointerIconin classView- Parameters:
event- The MotionEvent from a mouse- See Also:
-
setEnabled
public void setEnabled(boolean enabled) Description copied from class:ViewSet the enabled state of this view. The interpretation of the enabled state varies by subclass.- Overrides:
setEnabledin classView- Parameters:
enabled- True if this view is enabled, false otherwise.
-
getOffsetForPosition
public int getOffsetForPosition(float x, float y) Get the character offset closest to the specified absolute position. A typical use case is to pass the result ofMotionEvent.getX()andMotionEvent.getY()to this method.- Parameters:
x- The horizontal absolute position of a point on screeny- The vertical absolute position of a point on screen- Returns:
- the character offset for the character whose position is closest to the specified position. Returns -1 if there is no layout.
-