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

TextViewCompat

class TextViewCompat
kotlin.Any
   ↳ androidx.core.widget.TextViewCompat

Helper for accessing features in TextView.

Summary

Constants
static Int

The TextView does not auto-size text (default).

static Int

The TextView scales text size both horizontally and vertically to fit within the container.

Public methods
static Int
getAutoSizeMaxTextSize(@NonNull textView: TextView)

static Int
getAutoSizeMinTextSize(@NonNull textView: TextView)

static Int

static IntArray

static Int
getAutoSizeTextType(@NonNull textView: TextView)

Returns the type of auto-size set for this widget.

static ColorStateList?

Return the tint applied to any compound drawables.

static Mode?

Return the tint mode applied to any compound drawables.

static Array<Drawable!>

Returns drawables for the start, top, end, and bottom borders from the given text view.

static Int

Returns the distance between the first text baseline and the top of this TextView.

static Int

Returns the distance between the last text baseline and the bottom of this TextView.

static Int
getMaxLines(@NonNull textView: TextView)

Returns the maximum number of lines displayed in the given TextView, or -1 if the maximum height was set in pixels instead.

static Int
getMinLines(@NonNull textView: TextView)

Returns the minimum number of lines displayed in the given TextView, or -1 if the minimum height was set in pixels instead.

static PrecomputedTextCompat.Params
getTextMetricsParams(@NonNull textView: TextView)

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

static Unit
setAutoSizeTextTypeUniformWithConfiguration(@NonNull textView: TextView, autoSizeMinTextSize: Int, autoSizeMaxTextSize: Int, autoSizeStepGranularity: Int, unit: Int)

Specify whether this widget should automatically scale the text to try to perfectly fit within the layout bounds.

static Unit
setAutoSizeTextTypeUniformWithPresetSizes(@NonNull textView: TextView, @NonNull presetSizes: IntArray, unit: Int)

Specify whether this widget should automatically scale the text to try to perfectly fit within the layout bounds.

static Unit
setAutoSizeTextTypeWithDefaults(@NonNull textView: TextView, autoSizeTextType: Int)

Specify whether this widget should automatically scale the text to try to perfectly fit within the layout bounds by using the default auto-size configuration.

static Unit
setCompoundDrawableTintList(@NonNull textView: TextView, @Nullable tint: ColorStateList?)

Applies a tint to any compound drawables.

static Unit
setCompoundDrawableTintMode(@NonNull textView: TextView, @Nullable tintMode: Mode?)

Applies a tint mode to any compound drawables.

static Unit
setCompoundDrawablesRelative(@NonNull textView: TextView, @Nullable start: Drawable?, @Nullable top: Drawable?, @Nullable end: Drawable?, @Nullable bottom: Drawable?)

Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text.

static Unit
setCompoundDrawablesRelativeWithIntrinsicBounds(@NonNull textView: TextView, @Nullable start: Drawable?, @Nullable top: Drawable?, @Nullable end: Drawable?, @Nullable bottom: Drawable?)

Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text.

static Unit
setCompoundDrawablesRelativeWithIntrinsicBounds(@NonNull textView: TextView, @DrawableRes start: Int, @DrawableRes top: Int, @DrawableRes end: Int, @DrawableRes bottom: Int)

Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text.

static Unit
setCustomSelectionActionModeCallback(@NonNull textView: TextView, @NonNull callback: Callback)

Sets a selection action mode callback on a TextView.

static Unit
setFirstBaselineToTopHeight(@NonNull textView: TextView, @Px @IntRange(0) firstBaselineToTopHeight: Int)

Updates the top padding of the TextView so that firstBaselineToTopHeight is equal to the distance between the first text baseline and the top of this TextView.

static Unit
setLastBaselineToBottomHeight(@NonNull textView: TextView, @Px @IntRange(0) lastBaselineToBottomHeight: Int)

Updates the bottom padding of the TextView so that lastBaselineToBottomHeight is equal to the distance between the last text baseline and the bottom of this TextView.

static Unit
setLineHeight(@NonNull textView: TextView, @Px @IntRange(0) lineHeight: Int)

Sets an explicit line height for this TextView.

static Unit
setPrecomputedText(@NonNull textView: TextView, @NonNull precomputed: PrecomputedTextCompat)

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

static Unit
setTextAppearance(@NonNull textView: TextView, @StyleRes resId: Int)

Sets the text appearance from the specified style resource.

static Unit
setTextMetricsParams(@NonNull textView: TextView, @NonNull params: PrecomputedTextCompat.Params)

Apply the text layout parameter.

Constants

AUTO_SIZE_TEXT_TYPE_NONE

static val AUTO_SIZE_TEXT_TYPE_NONE: Int

The TextView does not auto-size text (default).

Value: TextView.AUTO_SIZE_TEXT_TYPE_NONE

AUTO_SIZE_TEXT_TYPE_UNIFORM

static val AUTO_SIZE_TEXT_TYPE_UNIFORM: Int

The TextView scales text size both horizontally and vertically to fit within the container.