Google 致力于为黑人社区推动种族平等。查看具体举措

AppCompatTextView

open class AppCompatTextView : TextView, TintableBackgroundView, TintableCompoundDrawablesView, AutoSizeableTextView
kotlin.Any
   ↳ android.view.View
   ↳ android.widget.TextView
   ↳ androidx.appcompat.widget.AppCompatTextView

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
<init>(@NonNull context: Context)

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?)

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?, defStyleAttr: Int)

Public methods
open Int

open Int

open CharSequence!

open TextClassifier

Returns the TextClassifier used by this TextView.

open PrecomputedTextCompat.Params

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

open InputConnection!

open Unit
setBackgroundDrawable(@Nullable background: Drawable?)

open Unit
setBackgroundResource(@DrawableRes resId: Int)

open Unit
setCompoundDrawables(@Nullable left: Drawable?, @Nullable top: Drawable?, @Nullable right: Drawable?, @Nullable bottom: Drawable?)

open Unit
setCompoundDrawablesRelative(@Nullable start: Drawable?, @Nullable top: Drawable?, @Nullable end: Drawable?, @Nullable bottom: Drawable?)

open Unit
setCompoundDrawablesRelativeWithIntrinsicBounds(@Nullable start: Drawable?, @Nullable top: Drawable?, @Nullable end: Drawable?, @Nullable bottom: Drawable?)

open Unit

open Unit
setCompoundDrawablesWithIntrinsicBounds(@Nullable left: Drawable?, @Nullable top: Drawable?, @Nullable right: Drawable?, @Nullable bottom: Drawable?)

open Unit
setCompoundDrawablesWithIntrinsicBounds(left: Int, top: Int, right: Int, bottom: Int)

open Unit

See TextViewCompat#setCustomSelectionActionModeCallback(TextView, ActionMode.Callback)

open Unit
setFirstBaselineToTopHeight(@Px @IntRange(0) firstBaselineToTopHeight: Int)

open Unit
setLastBaselineToBottomHeight(@Px @IntRange(0) lastBaselineToBottomHeight: Int)

open Unit
setLineHeight(@Px @IntRange(0) lineHeight: Int)

open Unit

Sets the PrecomputedTextCompat to the TextView.

open Unit
setTextAppearance(context: Context!, resId: Int)

open Unit
setTextClassifier(@Nullable textClassifier: TextClassifier?)

Sets the TextClassifier for this TextView.

open Unit

Set the precomputed text future.

open Unit

Apply the text layout parameter.

open Unit
setTextSize(unit: Int, size: Float)

open Unit
setTypeface(@Nullable tf: Typeface?, style: Int)

Protected methods
open Unit

open Unit
onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int)

open Unit
onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)

open Unit
onTextChanged(text: CharSequence!, start: Int, lengthBefore: Int, lengthAfter: Int)

Public constructors

<init>

AppCompatTextView(@NonNull context: Context)

<init>

AppCompatTextView(
    @NonNull context: Context,
    @Nullable attrs: AttributeSet?)

<init>

AppCompatTextView(
    @NonNull context: Context,
    @Nullable attrs: AttributeSet?,
    defStyleAttr: Int)

Public methods

getFirstBaselineToTopHeight

open fun getFirstBaselineToTopHeight(): Int

getLastBaselineToBottomHeight

open fun getLastBaselineToBottomHeight(): Int

getText

open fun getText(): CharSequence!

getTextClassifier

@NonNull @RequiresApi(26) open fun getTextClassifier(): TextClassifier

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

@NonNull open fun getTextMetricsParamsCompat(): PrecomputedTextCompat.Params

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

Return
PrecomputedTextCompat.Params a current PrecomputedTextCompat.Params

onCreateInputConnection

open fun onCreateInputConnection(outAttrs: EditorInfo!): InputConnection!

setBackgroundDrawable

open fun setBackgroundDrawable(@Nullable background: Drawable?): Unit

setBackgroundResource

open fun setBackgroundResource(@DrawableRes resId: Int): Unit

setCompoundDrawables

open fun setCompoundDrawables(
    @Nullable left: Drawable?,
    @Nullable top: Drawable?,
    @Nullable right: Drawable?,
    @Nullable bottom: Drawable?
): Unit

setCompoundDrawablesRelative

@RequiresApi(17) open fun setCompoundDrawablesRelative(
    @Nullable start: Drawable?,
    @Nullable top: Drawable?,
    @Nullable end: Drawable?,
    @Nullable bottom: Drawable?
): Unit

setCompoundDrawablesRelativeWithIntrinsicBounds

@RequiresApi(17) open fun setCompoundDrawablesRelativeWithIntrinsicBounds(
    @Nullable start: Drawable?,
    @Nullable top: Drawable?,
    @Nullable end: Drawable?,
    @Nullable bottom: Drawable?
): Unit

setCompoundDrawablesRelativeWithIntrinsicBounds

@RequiresApi(17) open fun setCompoundDrawablesRelativeWithIntrinsicBounds(
    start: Int,
    top: Int,
    end: Int,
    bottom: Int
): Unit

setCompoundDrawablesWithIntrinsicBounds

open fun setCompoundDrawablesWithIntrinsicBounds(
    @Nullable left: Drawable?,
    @Nullable top: Drawable?,
    @Nullable right: Drawable?,
    @Nullable bottom: Drawable?
): Unit

setCompoundDrawablesWithIntrinsicBounds

open fun setCompoundDrawablesWithIntrinsicBounds(
    left: Int,
    top: Int,