AppCompatTextView

public class AppCompatTextView extends TextView implements TintableBackgroundView, TintableCompoundDrawablesView, EmojiCompatConfigurationView

Known direct subclasses
EmojiAppCompatTextView

AppCompatTextView widget enhanced with emoji capability by using EmojiTextViewHelper.


A TextView which supports compatible features on older versions of the platform, including:

This will automatically be used when you use TextView in your layouts and the top-level activity / dialog is provided by appcompat. You should only need to manually use this class when writing custom views.

Summary

Public constructors

AppCompatTextView(
    @NonNull Context context,
    @Nullable AttributeSet attrs,
    int defStyleAttr
)

Public methods

@Nullable ActionMode.Callback
int
int
CharSequence
@NonNull TextClassifier

Returns the TextClassifier used by this TextView.

@NonNull PrecomputedTextCompat.Params

Gets the parameters for text layout precomputation, for use with PrecomputedTextCompat.

boolean
InputConnection
void
setAllCaps(boolean allCaps)
void

This method is deprecated.

void
void
setCompoundDrawables(
    @Nullable Drawable left,
    @Nullable Drawable top,
    @Nullable Drawable right,
    @Nullable Drawable bottom
)
void
@RequiresApi(value = Build.VERSION_CODES.JELLY_BEAN_MR1)
setCompoundDrawablesRelative(
    @Nullable Drawable start,
    @Nullable Drawable top,
    @Nullable Drawable end,
    @Nullable Drawable bottom
)
void
@RequiresApi(value = Build.VERSION_CODES.JELLY_BEAN_MR1)
setCompoundDrawablesRelativeWithIntrinsicBounds(
    @Nullable Drawable start,
    @Nullable Drawable top,
    @Nullable Drawable end,
    @Nullable Drawable bottom
)
void
@RequiresApi(value = Build.VERSION_CODES.JELLY_BEAN_MR1)
setCompoundDrawablesRelativeWithIntrinsicBounds(
    int start,
    int top,
    int end,
    int bottom
)
void
setCompoundDrawablesWithIntrinsicBounds(
    @Nullable Drawable left,
    @Nullable Drawable top,
    @Nullable Drawable right,
    @Nullable Drawable bottom
)
void
setCompoundDrawablesWithIntrinsicBounds(
    int left,
    int top,
    int right,
    int bottom
)
void

See setCustomSelectionActionModeCallback

void
setEmojiCompatEnabled(boolean enabled)

Configure emoji fallback behavior using EmojiCompat.

void
setFilters(@NonNull InputFilter[] filters)
void
setFirstBaselineToTopHeight(
    @Px @IntRange(from = 0) int firstBaselineToTopHeight
)
void
setLastBaselineToBottomHeight(
    @Px @IntRange(from = 0) int lastBaselineToBottomHeight
)
void
setLineHeight(@Px @IntRange(from = 0) int lineHeight)
void
setLineHeight(int unit, @FloatRange(from = 0) float lineHeight)
void

Sets the PrecomputedTextCompat to the TextView.

void
setTextAppearance(Context context, int resId)

This method is deprecated.

void

Sets the TextClassifier for this TextView.

void

Set the precomputed text future.

void

Apply the text layout parameter.

void
setTextSize(int unit, float size)
void
setTypeface(@Nullable Typeface tf, int style)

Protected methods

void
void
void
onLayout(boolean changed, int left, int top, int right, int bottom)
void
onMeasure(int widthMeasureSpec, int heightMeasureSpec)
void
onTextChanged(
    CharSequence text,
    int start,
    int lengthBefore,
    int lengthAfter
)

Inherited Constants

From android.widget.TextView
static final int
static final int
static final int
From android.view.View
static final int
static final int
static final int
static final int
static final int
static final int
static final Property<ViewFloat>
static final int
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = "creditCardExpirationDate"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = "creditCardExpirationMonth"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = "creditCardExpirationYear"
static final String
static final String
AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = "creditCardSecurityCode"
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int[]
static final int[]
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int
GONE = 8
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
KEEP_SCREEN_ON = 67108864
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
NO_ID = -1
static final int
static final int
static final int
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int[]
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final String
VIEW_LOG_TAG = "View"
static final int
static final int[]
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>

Inherited methods

From android.widget.TextView
void
addExtraDataToAccessibilityNodeInfo(
    AccessibilityNodeInfo info,
    String extraDataKey,
    Bundle arguments
)
void
final void
void
void
boolean
bringPointIntoView(int offset)
void
void
int
void
int
int
void
debug(int depth)
boolean
void
drawableHotspotChanged(float x, float y)
void
boolean
void
findViewsWithText(
    ArrayList<View> outViews,
    CharSequence searched,
    int flags
)
CharSequence
final int
String[]
int
AutofillValue
int
int
int
int
BlendMode
ColorStateList
PorterDuff.Mode
Drawable[]
Drawable[]
int
int
int
int
int
int
final int
final int
ActionMode.Callback
boolean
MovementMethod
Editable
TextUtils.TruncateAt
CharSequence
int
int
InputFilter[]
void
int
int
String
String
boolean
int
int
Highlights
CharSequence
final ColorStateList
int
int
CharSequence
LocaleList
int
boolean
Bundle
getInputExtras(boolean create)
int
int
final KeyListener
final Layout
float
int
float
int
getLineBounds(int line, Rect bounds)
int
int
int
int
float
float
final ColorStateList
final boolean
int
int
int
int
int
int
int
int
int
final MovementMethod
int
getOffsetForPosition(float x, float y)
TextPaint
int
String
float
int
int
int[]
int
int
int
float
float
float
final boolean
final ColorStateList
Drawable
TextDirectionHeuristic
Locale
LocaleList
PrecomputedText.Params
float
Drawable
Drawable
Drawable
float
int
int
int
int
int
int
int
int
final TransformationMethod
Typeface
URLSpan[]
boolean
boolean
void
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
void
int
boolean
void
void
boolean
void
void
void
void
int[]
onCreateDrawableState(int extraSpace)
void
onCreateViewTranslationRequest(
    int[] supportedFormats,
    Consumer<ViewTranslationRequest> requestsCollector
)
boolean
void
onDraw(Canvas canvas)
void
onEditorAction(int actionCode)
void
void
onFocusChanged(
    boolean focused,
    int direction,
    Rect previouslyFocusedRect
)
boolean
boolean
onKeyDown(int keyCode, KeyEvent event)
boolean
onKeyMultiple(int keyCode, int repeatCount, KeyEvent event)
boolean
onKeyPreIme(int keyCode, KeyEvent event)
boolean
onKeyShortcut(int keyCode, KeyEvent event)
boolean
onKeyUp(int keyCode, KeyEvent event)
boolean
boolean
ContentInfo
PointerIcon
onResolvePointerIcon(MotionEvent event, int pointerIndex)
void
void
onRtlPropertiesChanged(int layoutDirection)
Parcelable
void
onScreenStateChanged(int screenState)
void
onScrollChanged(int horiz, int vert, int oldHoriz, int oldVert)
void
onSelectionChanged(int selStart, int selEnd)
boolean
boolean
boolean
void
onVisibilityAggregated(boolean isVisible)
void
onVisibilityChanged(View changedView, int visibility)
void
onWindowFocusChanged(boolean hasWindowFocus)
boolean
void
void
final void
setAutoLinkMask(int mask)
void
setBreakStrategy(int breakStrategy)
void
void
void
void
void
setCursorVisible(boolean visible)
void
final void
void
setElegantTextHeight(boolean elegant)
void
void
setEms(int ems)
void
setEnabled(boolean enabled)
void
void
void
setFallbackLineSpacing(boolean enabled)
void
void
void
setFontFeatureSettings(String fontFeatureSettings)
boolean
setFontVariationSettings(String fontVariationSettings)
boolean
setFrame(int l, int t, int r, int b)
void
setFreezesText(boolean freezesText)
void
setGravity(int gravity)
void
setHeight(int pixels)
void
setHighlightColor(int color)
void
final void
final void
setHintTextColor(int color)
void
setHorizontallyScrolling(boolean whether)
void
setHyphenationFrequency(int hyphenationFrequency)
void
setImeActionLabel(CharSequence label, int actionId)
void
void
setImeOptions(int imeOptions)
void
setIncludeFontPadding(boolean includepad)
void
setInputExtras(int xmlResId)
void
setInputType(int type)
void
setJustificationMode(int justificationMode)
void
void
setLetterSpacing(float letterSpacing)
void
setLineBreakStyle(int lineBreakStyle)
void
setLineBreakWordStyle(int lineBreakWordStyle)
void
setLineSpacing(float add, float mult)
void
setLines(int lines)
final void
setLinkTextColor(int color)
final void
setLinksClickable(boolean whether)
void
setMarqueeRepeatLimit(int marqueeLimit)
void
setMaxEms(int maxEms)
void
setMaxHeight(int maxPixels)
void
setMaxLines(int maxLines)
void
setMaxWidth(int maxPixels)
void
setMinEms(int minEms)
void
setMinHeight(int minPixels)
void
setMinLines(int minLines)
void
setMinWidth(int minPixels)
final void
void
void
setPadding(int left, int top, int right, int bottom)
void
setPaddingRelative(int start, int top, int end, int bottom)
void
setPaintFlags(int flags)
void
void
setRawInputType(int type)
void
void
void
void
setSelectAllOnFocus(boolean selectAllOnFocus)
void
setSelected(boolean selected)
void
setShadowLayer(float radius, float dx, float dy, int color)
final void
void
final void
final void
void
setTextAppearance(int resId)
void
setTextColor(int color)
void
setTextCursorDrawable(Drawable textCursorDrawable)
void
setTextIsSelectable(boolean selectable)
final void
void
void
void
void
setTextScaleX(float size)
void
setTextSelectHandle(Drawable textSelectHandle)
void
setTextSelectHandleLeft(Drawable textSelectHandleLeft)
void
setTextSelectHandleRight(Drawable textSelectHandleRight)
void
setTextSize(float size)
final void
void
setWidth(int pixels)
boolean
boolean
From android.view.View
void
void
addFocusables(ArrayList<View> views, int direction)
void
void
void
void
void
ViewPropertyAnimator
void
boolean
void
void

This method is deprecated.

void
boolean
boolean
boolean
boolean
boolean
canScrollHorizontally(int direction)
boolean
canScrollVertically(int direction)
final void
final void
boolean
void
void
void
static int
combineMeasuredStates(int curState, int newState)
int
int
WindowInsets
int
AccessibilityNodeInfo
void
void

This method is deprecated.

WindowInsets
boolean
void
void
dispatchCreateViewTranslationRequest(
    Map<AutofillId, long[]> viewIds,
    int[] supportedFormats,
    TranslationCapability capability,
    List<ViewTranslationRequest> requests
)
void
boolean
void
void
dispatchDrawableHotspotChanged(float x, float y)
void
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
dispatchNestedFling(float velocityX, float velocityY, boolean consumed)
boolean
dispatchNestedPreFling(float velocityX, float velocityY)
boolean
dispatchNestedPrePerformAccessibilityAction(
    int action,
    Bundle arguments
)
boolean
dispatchNestedPreScroll(
    int dx,
    int dy,
    int[] consumed,
    int[] offsetInWindow
)
boolean
dispatchNestedScroll(
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed,
    int[] offsetInWindow
)
void
dispatchPointerCaptureChanged(boolean hasCapture)
boolean
void
void
void
void
void
dispatchScrollCaptureSearch(
    Rect localVisibleRect,
    Point windowOffset,
    Consumer<ScrollCaptureTarget> targets
)
void
dispatchSetActivated(boolean activated)
void
dispatchSetPressed(boolean pressed)
void
dispatchSetSelected(boolean selected)
void
void

This method is deprecated.

boolean
boolean
boolean
dispatchUnhandledMove(View focused, int direction)
void
dispatchVisibilityChanged(View changedView, int visibility)
void
dispatchWindowFocusChanged(boolean hasFocus)
void
void
WindowInsets
WindowInsetsAnimation.Bounds
void

This method is deprecated.

void
void
draw(Canvas canvas)
View
final OnBackInvokedDispatcher
final T
<T extends View> findViewById(int id)
final T
<T extends View> findViewWithTag(Object tag)
boolean

This method is deprecated.

View
focusSearch(int direction)
void
forceHasOverlappingRendering(boolean hasOverlappingRendering)
void
boolean
void
generateDisplayHash(
    String hashAlgorithm,
    Rect bounds,
    Executor executor,
    DisplayHashResultCallback callback
)
static int
View.AccessibilityDelegate
int
AccessibilityNodeProvider
CharSequence
int
int
String
String
float
Animation
Matrix
IBinder
int[]
Map<IntegerInteger>
final AutofillId
Drawable
BlendMode
ColorStateList
PorterDuff.Mode
final int
float
float
Rect
boolean
final boolean
final ContentCaptureSession
CharSequence
final Context
ContextMenu.ContextMenuInfo
final boolean
static int
getDefaultSize(int size, int measureSpec)
Display
final int[]
Bitmap

This method is deprecated.

int

This method is deprecated.

int

This method is deprecated.

void
long
float
int
boolean
boolean
int
ArrayList<View>
getFocusables(int direction)
Drawable
int
BlendMode
ColorStateList
PorterDuff.Mode
boolean
getGlobalVisibleRect(Rect r, Point globalOffset)
Handler
float
float
float
float
Runnable
final boolean
final int
void
getHitRect(Rect outRect)
int
int
Drawable
Drawable
int
int
int
int
boolean
KeyEvent.DispatcherState
int
int
int
ViewGroup.LayoutParams
final int
final boolean
void
getLocationInSurface(int[] location)
void
getLocationInWindow(int[] outLocation)
void
getLocationOnScreen(int[] outLocation)
Matrix
final int
final int
final int
final int
final int
int
int
int
int
int
int
int
int
View.OnFocusChangeListener
int
ViewOutlineProvider
int
int
ViewOverlay
int
int
int
int
int
int
final ViewParent
ViewParent
float
float
PointerIcon
final List<Rect>
String[]
Resources
final boolean
final int
AttachedSurfaceControl
View
WindowInsets
float
float
float
float
float
int
int
int
int
int
int
final int
final int
int
int
final CharSequence
StateListAnimator
int
int
List<Rect>
int

This method is deprecated.

Object
int
int
CharSequence
final int
float
TouchDelegate
ArrayList<View>
float
String
float
float
float
long
int
int
Drawable
Drawable
int
ViewTranslationResponse
ViewTreeObserver
int
final int
int
WindowId
WindowInsetsController
int

This method is deprecated.

IBinder
int
void
float
float
float
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
static View
inflate(Context context, int resource, ViewGroup root)
void

This method is deprecated.

void
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean

This method is deprecated.

boolean
boolean
final boolean
final boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
final boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
View
keyboardNavigationClusterSearch(View currentCluster, int direction)
void
layout(int l, int t, int r, int b)
final void
measure(int widthMeasureSpec, int heightMeasureSpec)
static int[]
mergeDrawableStates(int[] baseState, int[] additionalState)
void
offsetLeftAndRight(int offset)
void
offsetTopAndBottom(int offset)
void
void
WindowInsets
void
boolean
void
onCreateVirtualViewTranslationRequests(
    long[] virtualIds,
    int[] supportedFormats,
    Consumer<ViewTranslationRequest> requestsCollector
)
void
onDisplayHint(int hint)
void
final void
boolean
void
void
void
onHoverChanged(boolean hovered)
boolean
void
void
boolean
onKeyLongPress(int keyCode, KeyEvent event)
void
onOverScrolled(
    int scrollX,
    int scrollY,
    boolean clampedX,
    boolean clampedY
)
void
onPointerCaptureChange(boolean hasCapture)
void
void
onProvideAutofillStructure(ViewStructure structure, int flags)
void
void
void
void
void
onScrollCaptureSearch(
    Rect localVisibleRect,
    Point windowOffset,
    Consumer<ScrollCaptureTarget> targets
)
boolean
onSetAlpha(int alpha)
void
onSizeChanged(int w, int h, int oldw, int oldh)
void
void
void
void

This method is deprecated.

void
onWindowVisibilityChanged(int visibility)
boolean
overScrollBy(
    int deltaX,
    int deltaY,
    int scrollX,
    int scrollY,
    int scrollRangeX,
    int scrollRangeY,
    int maxOverScrollX,
    int maxOverScrollY,
    boolean isTouchEvent
)
boolean
performAccessibilityAction(int action, Bundle arguments)
boolean
boolean
performContextClick(float x, float y)
boolean
performHapticFeedback(int feedbackConstant)
ContentInfo
void
playSoundEffect(int soundConstant)
boolean
post(Runnable action)
boolean
postDelayed(Runnable action, long delayMillis)
void
void
postInvalidateDelayed(long delayMilliseconds)
void
void
void
postOnAnimationDelayed(Runnable action, long delayMillis)
void
void
boolean
void
void
void
void
void

This method is deprecated.

final boolean
final boolean
void
void
boolean
final void
final T
<T extends View> requireViewById(int id)
void
static int
resolveSize(int size, int measureSpec)
static int
resolveSizeAndState(int size, int measureSpec, int childMeasuredState)
boolean
void
final void
saveAttributeDataForStyleable(
    Context context,
    int[] styleable,
    AttributeSet attrs,
    TypedArray t,
    int defStyleAttr,
    int defStyleRes
)
void
void
scheduleDrawable(Drawable who, Runnable what, long when)
void
scrollBy(int x, int y)
void
scrollTo(int x, int y)
void
sendAccessibilityEvent(int eventType)
void
setAccessibilityDataSensitive(int accessibilityDataSensitive)
void
void
setAccessibilityHeading(boolean isHeading)
void
void
setAccessibilityPaneTitle(CharSequence accessibilityPaneTitle)
void
void
void
setActivated(boolean activated)
void
setAllowClickWhenDisabled(boolean clickableWhenDisabled)
void
void
void
setAlpha(float alpha)
void
void
void
setAutoHandwritingEnabled(boolean enabled)
void
setAutofillHints(String[] autofillHints)
void
void
setBackground(Drawable background)
void
setBackgroundColor(int color)
void
void
void
final void
setBottom(int bottom)
void
setCameraDistance(float distance)
void
setClickable(boolean clickable)
void
setClipBounds(Rect clipBounds)
void
setClipToOutline(boolean clipToOutline)
void
void
setContentDescription(CharSequence contentDescription)
void
setContextClickable(boolean contextClickable)
void
setDefaultFocusHighlightEnabled(boolean defaultFocusHighlightEnabled)
void

This method is deprecated.

void
setDrawingCacheEnabled(boolean enabled)

This method is deprecated.

void

This method is deprecated.

void
void
setElevation(float elevation)
void
setFadingEdgeLength(int length)
void
void
setFitsSystemWindows(boolean fitSystemWindows)
void
setFocusable(boolean focusable)
void
setFocusableInTouchMode(boolean focusableInTouchMode)
void
setFocusedByDefault(boolean isFocusedByDefault)
void
setForceDarkAllowed(boolean allow)
void
setForeground(Drawable foreground)
void
setForegroundGravity(int gravity)
void
void
void
void
setHandwritingBoundsOffsets(
    float offsetLeft,
    float offsetTop,
    float offsetRight,
    float offsetBottom
)
void
void
setHapticFeedbackEnabled(boolean hapticFeedbackEnabled)
void
setHasTransientState(boolean hasTransientState)
void
setHorizontalFadingEdgeEnabled(boolean horizontalFadingEdgeEnabled)
void
setHorizontalScrollBarEnabled(boolean horizontalScrollBarEnabled)
void
void
void
setHovered(boolean hovered)
void
setId(int id)
void
void
void
void
setIsCredential(boolean isCredential)
void
setIsHandwritingDelegate(boolean isHandwritingDelegate)
void
setKeepScreenOn(boolean keepScreenOn)
void
setKeyboardNavigationCluster(boolean isCluster)
void
setLabelFor(int id)
void
void
setLayerType(int layerType, Paint paint)
void
setLayoutDirection(int layoutDirection)
void
final void
setLeft(int left)
final void
setLeftTopRightBottom(int left, int top, int right, int bottom)
void
setLongClickable(boolean longClickable)
final void
setMeasuredDimension(int measuredWidth, int measuredHeight)
void
setMinimumHeight(int minHeight)
void
setMinimumWidth(int minWidth)
void
setNestedScrollingEnabled(boolean enabled)
void
setNextClusterForwardId(int nextClusterForwardId)
void
setNextFocusDownId(int nextFocusDownId)
void
setNextFocusForwardId(int nextFocusForwardId)
void
setNextFocusLeftId(int nextFocusLeftId)
void
setNextFocusRightId(int nextFocusRightId)
void
setNextFocusUpId(int nextFocusUpId)
void
void
void
void
void
void
void
void
void
void
void
void
setOnReceiveContentListener(
    String[] mimeTypes,
    OnReceiveContentListener listener
)
void
void

This method is deprecated.

void
void
void
void
void
setOverScrollMode(int overScrollMode)
void
setPivotX(float pivotX)
void
setPivotY(float pivotY)
void
final void
setPreferKeepClear(boolean preferKeepClear)
final void
void
setPressed(boolean pressed)
void
final void
setRevealOnFocusHint(boolean revealOnFocus)
final void
setRight(int right)
void
setRotation(float rotation)
void
setRotationX(float rotationX)
void
setRotationY(float rotationY)
void
setSaveEnabled(boolean enabled)
void
setSaveFromParentEnabled(boolean enabled)
void
setScaleX(float scaleX)
void
setScaleY(float scaleY)
void
setScreenReaderFocusable(boolean screenReaderFocusable)
void
setScrollBarDefaultDelayBeforeFade(
    int scrollBarDefaultDelayBeforeFade
)
void
setScrollBarFadeDuration(int scrollBarFadeDuration)
void
setScrollBarSize(int scrollBarSize)
void
setScrollBarStyle(int style)
final void
void
void
setScrollContainer(boolean isScrollContainer)
void
setScrollIndicators(int indicators)
void
setScrollX(int value)
void
setScrollY(int value)
void
setScrollbarFadingEnabled(boolean fadeScrollbars)
void
setSoundEffectsEnabled(boolean soundEffectsEnabled)
void
void
void
void
setSystemUiVisibility(int visibility)

This method is deprecated.

void
void
setTextAlignment(int textAlignment)
void
setTextDirection(int textDirection)
void
final void
setTop(int top)
void
void
setTransitionAlpha(float alpha)
final void
setTransitionName(String transitionName)
void
setTransitionVisibility(int visibility)
void
setTranslationX(float translationX)
void
setTranslationY(float translationY)
void
setTranslationZ(float translationZ)
void
setVerticalFadingEdgeEnabled(boolean verticalFadingEdgeEnabled)
void
setVerticalScrollBarEnabled(boolean verticalScrollBarEnabled)
void
void
void
void
void
setVisibility(int visibility)
void
setWillNotCacheDrawing(boolean willNotCacheDrawing)

This method is deprecated.

void
setWillNotDraw(boolean willNotDraw)
void
void
setX(float x)
void
setY(float y)
void
setZ(float z)
ActionMode
void
final boolean
startDrag(
    ClipData data,
    View.DragShadowBuilder shadowBuilder,
    Object myLocalState,
    int flags
)

This method is deprecated.

final boolean
startDragAndDrop(
    ClipData data,
    View.DragShadowBuilder shadowBuilder,
    Object myLocalState,
    int flags
)
boolean
void
String
void
void
void
final void
boolean

This method is deprecated.

boolean

Public constructors

AppCompatTextView

Added in 1.1.0
public AppCompatTextView(@NonNull Context context)

AppCompatTextView

Added in 1.1.0
public AppCompatTextView(@NonNull Context context, @Nullable AttributeSet attrs)

AppCompatTextView

Added in 1.1.0
public AppCompatTextView(
    @NonNull Context context,
    @Nullable AttributeSet attrs,
    int defStyleAttr
)

Public methods

getCustomSelectionActionModeCallback

public @Nullable ActionMode.Callback getCustomSelectionActionModeCallback()

getFirstBaselineToTopHeight

public int getFirstBaselineToTopHeight()

getLastBaselineToBottomHeight

public int getLastBaselineToBottomHeight()

getText

public CharSequence getText()

getTextClassifier

@RequiresApi(api = 26)
public @NonNull TextClassifier getTextClassifier()

Returns the TextClassifier used by this TextView. If no TextClassifier has been set, this TextView uses the default set by the android.view.textclassifier.TextClassificationManager.

getTextMetricsParamsCompat

Added in 1.1.0
public @NonNull PrecomputedTextCompat.Params getTextMetricsParamsCompat()

Gets the parameters for text layout precomputation, for use with PrecomputedTextCompat.

isEmojiCompatEnabled

Added in 1.7.0-alpha03
public boolean isEmojiCompatEnabled()
Returns
boolean

the current enabled state, set via setEmojiCompatEnabled

onCreateInputConnection

public InputConnection onCreateInputConnection(EditorInfo outAttrs)

setAllCaps

public void setAllCaps(boolean allCaps)

setBackgroundDrawable

Added in 1.1.0
public void setBackgroundDrawable(@Nullable Drawable background)

setBackgroundResource

public void setBackgroundResource(@DrawableRes int resId)

setCompoundDrawables

public void setCompoundDrawables(
    @Nullable Drawable left,
    @Nullable Drawable top,
    @Nullable Drawable right,
    @Nullable Drawable bottom
)

setCompoundDrawablesRelative

@RequiresApi(value = Build.VERSION_CODES.JELLY_BEAN_MR1)
public void setCompoundDrawablesRelative(
    @Nullable Drawable start,
    @Nullable Drawable top,
    @Nullable Drawable end,
    @Nullable Drawable bottom
)

setCompoundDrawablesRelativeWithIntrinsicBounds

@RequiresApi(value = Build.VERSION_CODES.JELLY_BEAN_MR1)
public void setCompoundDrawablesRelativeWithIntrinsicBounds(
    @Nullable Drawable start,
    @Nullable Drawable top,
    @Nullable Drawable end,
    @Nullable Drawable bottom
)

setCompoundDrawablesRelativeWithIntrinsicBounds

@RequiresApi(value = Build.VERSION_CODES.JELLY_BEAN_MR1)
public void setCompoundDrawablesRelativeWithIntrinsicBounds(
    int start,
    int top,
    int end,
    int bottom
)

setCompoundDrawablesWithIntrinsicBounds

public void setCompoundDrawablesWithIntrinsicBounds(
    @Nullable Drawable left,
    @Nullable Drawable top,
    @Nullable Drawable right,
    @Nullable Drawable bottom
)

setCompoundDrawablesWithIntrinsicBounds

public void setCompoundDrawablesWithIntrinsicBounds(
    int left,
    int top,
    int right,
    int bottom
)

setCustomSelectionActionModeCallback

public void setCustomSelectionActionModeCallback(
    @Nullable ActionMode.Callback actionModeCallback
)

See setCustomSelectionActionModeCallback

setEmojiCompatEnabled

Added in 1.7.0-alpha03
public void setEmojiCompatEnabled(boolean enabled)

Configure emoji fallback behavior using EmojiCompat. When enabled, this View will attempt to use EmojiCompat to enabled missing emojis. When disabled, this View will not display missing emojis using EmojiCompat. EmojiCompat must be correctly configured on a device for this to have an effect, which will happen by default if a correct downloadable fonts provider is installed on the device. If you manually configure EmojiCompat by calling EmojiCompat init after this View is constructed, you may call this method again to enable EmojiCompat on this text view. For more information about EmojiCompat configuration see the emoji2 module.

Parameters
boolean enabled

if true, display missing emoji using EmojiCompat, otherwise display missing emoji using a fallback glyph "□" (known as tofu)

setFilters

public void setFilters(@NonNull InputFilter[] filters)

setFirstBaselineToTopHeight

public void setFirstBaselineToTopHeight(
    @Px @IntRange(from = 0) int firstBaselineToTopHeight
)

setLastBaselineToBottomHeight

public void setLastBaselineToBottomHeight(
    @Px @IntRange(from = 0) int lastBaselineToBottomHeight
)

setLineHeight

public void setLineHeight(@Px @IntRange(from = 0) int lineHeight)

setLineHeight

public void setLineHeight(int unit, @FloatRange(from = 0) float lineHeight)

setPrecomputedText

Added in 1.1.0
public void setPrecomputedText(@NonNull PrecomputedTextCompat precomputed)

Sets the PrecomputedTextCompat to the TextView. If the given PrecomputeTextCompat is not compatible with textView, throws an IllegalArgumentException.

Parameters
@NonNull PrecomputedTextCompat precomputed

the precomputed text

Throws
java.lang.IllegalArgumentException

if precomputed text is not compatible with textView.

setTextAppearance

Added in 1.1.0
public void setTextAppearance(Context context, int resId)

setTextClassifier

@RequiresApi(api = 26)
public void setTextClassifier(@Nullable TextClassifier textClassifier)

Sets the TextClassifier for this TextView.

setTextFuture

Added in 1.1.0
public void setTextFuture(@Nullable Future<PrecomputedTextCompat> future)

Set the precomputed text future. This method sets future of the precomputed text instead of immediately applying text to the TextView. Anything layout related property changes, text size, typeface, letter spacing, etc after this method call will causes IllegalArgumentException during View measurement. See getTextFuture for more detail.

Parameters
@Nullable Future<PrecomputedTextCompat> future

a future for the precomputed text

See also
getTextFuture

setTextMetricsParamsCompat

Added in 1.1.0
public void setTextMetricsParamsCompat(@NonNull PrecomputedTextCompat.Params params)

Apply the text layout parameter. Update the TextView parameters to be compatible with PrecomputedTextCompat.Params.

setTextSize

public void setTextSize(int unit, float size)

setTypeface

public void setTypeface(@Nullable Typeface tf, int style)

Protected methods

drawableStateChanged

protected void drawableStateChanged()

onDetachedFromWindow

protected void onDetachedFromWindow()

onLayout

protected void onLayout(boolean changed, int left, int top, int right, int bottom)

onMeasure

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

onTextChanged

protected void onTextChanged(
    CharSequence text,
    int start,
    int lengthBefore,
    int lengthAfter
)