# TextViewCompat

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/widget/TextViewCompat.java+class:androidx.core.widget.TextViewCompat) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***

<br />

```
class TextViewCompat
```

<br />

*** ** * ** ***

Helper for accessing features in `https://developer.android.com/reference/android/widget/TextView.html`.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#AUTO_SIZE_TEXT_TYPE_NONE() = 0` The TextView does not auto-size text (default). |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#AUTO_SIZE_TEXT_TYPE_UNIFORM() = 1` The TextView scales text size both horizontally and vertically to fit within the container. |

| ### Public functions |
|---|---|
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#getAutoSizeMaxTextSize(android.widget.TextView)(textView: https://developer.android.com/reference/android/widget/TextView.html)` name android:autoSizeMaxTextSize |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#getAutoSizeMinTextSize(android.widget.TextView)(textView: https://developer.android.com/reference/android/widget/TextView.html)` name android:autoSizeMinTextSize |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#getAutoSizeStepGranularity(android.widget.TextView)(textView: https://developer.android.com/reference/android/widget/TextView.html)` name android:autoSizeStepGranularity |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#getAutoSizeTextAvailableSizes(android.widget.TextView)(textView: https://developer.android.com/reference/android/widget/TextView.html)` name android:autoSizePresetSizes |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#getAutoSizeTextType(android.widget.TextView)(textView: https://developer.android.com/reference/android/widget/TextView.html)` Returns the type of auto-size set for this widget. |
| `java-static https://developer.android.com/reference/android/content/res/ColorStateList.html?` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#getCompoundDrawableTintList(android.widget.TextView)(textView: https://developer.android.com/reference/android/widget/TextView.html)` Return the tint applied to any compound drawables. |
| `java-static https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html?` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#getCompoundDrawableTintMode(android.widget.TextView)(textView: https://developer.android.com/reference/android/widget/TextView.html)` Return the tint mode applied to any compound drawables. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/android/graphics/drawable/Drawable.html!>` | `@https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith(expression = "textView.getCompoundDrawablesRelative()") [getCompoundDrawablesRelative](https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#getCompoundDrawablesRelative(android.widget.TextView))(textView: https://developer.android.com/reference/android/widget/TextView.html)` **This function is deprecated.** Call `https://developer.android.com/reference/android/widget/TextView.html#getCompoundDrawablesRelative()` directly. <br /> |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#getFirstBaselineToTopHeight(android.widget.TextView)(textView: https://developer.android.com/reference/android/widget/TextView.html)` Returns the distance between the first text baseline and the top of this TextView. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#getLastBaselineToBottomHeight(android.widget.TextView)(textView: https://developer.android.com/reference/android/widget/TextView.html)` Returns the distance between the last text baseline and the bottom of this TextView. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith(expression = "textView.getMaxLines()") [getMaxLines](https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#getMaxLines(android.widget.TextView))(textView: https://developer.android.com/reference/android/widget/TextView.html)` **This function is deprecated.** Call `https://developer.android.com/reference/android/widget/TextView.html#getMaxLines()` directly. <br /> |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith(expression = "textView.getMinLines()") [getMinLines](https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#getMinLines(android.widget.TextView))(textView: https://developer.android.com/reference/android/widget/TextView.html)` **This function is deprecated.** Call `https://developer.android.com/reference/android/widget/TextView.html#getMinLines()` directly. <br /> |
| `java-static https://developer.android.com/reference/kotlin/androidx/core/text/PrecomputedTextCompat.Params` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#getTextMetricsParams(android.widget.TextView)(textView: https://developer.android.com/reference/android/widget/TextView.html)` Gets the parameters for text layout precomputation, for use with `https://developer.android.com/reference/kotlin/androidx/core/text/PrecomputedTextCompat`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setAutoSizeTextTypeUniformWithConfiguration(android.widget.TextView,int,int,int,int)( textView: https://developer.android.com/reference/android/widget/TextView.html, autoSizeMinTextSize: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, autoSizeMaxTextSize: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, autoSizeStepGranularity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, unit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Specify whether this widget should automatically scale the text to try to perfectly fit within the layout bounds. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setAutoSizeTextTypeUniformWithPresetSizes(android.widget.TextView,int[],int)( textView: https://developer.android.com/reference/android/widget/TextView.html, presetSizes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>, unit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Specify whether this widget should automatically scale the text to try to perfectly fit within the layout bounds. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setAutoSizeTextTypeWithDefaults(android.widget.TextView,int)( textView: https://developer.android.com/reference/android/widget/TextView.html, autoSizeTextType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` 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. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setCompoundDrawableTintList(android.widget.TextView,android.content.res.ColorStateList)(textView: https://developer.android.com/reference/android/widget/TextView.html, tint: https://developer.android.com/reference/android/content/res/ColorStateList.html?)` Applies a tint to any compound drawables. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setCompoundDrawableTintMode(android.widget.TextView,android.graphics.PorterDuff.Mode)( textView: https://developer.android.com/reference/android/widget/TextView.html, tintMode: https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html? )` Applies a tint mode to any compound drawables. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith(expression = "textView.setCompoundDrawablesRelative(start, top, end, bottom)") [setCompoundDrawablesRelative](https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setCompoundDrawablesRelative(android.widget.TextView,android.graphics.drawable.Drawable,android.graphics.drawable.Drawable,android.graphics.drawable.Drawable,android.graphics.drawable.Drawable))( textView: https://developer.android.com/reference/android/widget/TextView.html, start: https://developer.android.com/reference/android/graphics/drawable/Drawable.html?, top: https://developer.android.com/reference/android/graphics/drawable/Drawable.html?, end: https://developer.android.com/reference/android/graphics/drawable/Drawable.html?, bottom: https://developer.android.com/reference/android/graphics/drawable/Drawable.html? )` **This function is deprecated.** Call setCompoundDrawablesRelative directly. <br /> |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith(expression = "textView.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom)") [setCompoundDrawablesRelativeWithIntrinsicBounds](https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setCompoundDrawablesRelativeWithIntrinsicBounds(android.widget.TextView,android.graphics.drawable.Drawable,android.graphics.drawable.Drawable,android.graphics.drawable.Drawable,android.graphics.drawable.Drawable))( textView: https://developer.android.com/reference/android/widget/TextView.html, start: https://developer.android.com/reference/android/graphics/drawable/Drawable.html?, top: https://developer.android.com/reference/android/graphics/drawable/Drawable.html?, end: https://developer.android.com/reference/android/graphics/drawable/Drawable.html?, bottom: https://developer.android.com/reference/android/graphics/drawable/Drawable.html? )` **This function is deprecated.** Call setCompoundDrawablesRelativeWithIntrinsicBounds directly. <br /> |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith(expression = "textView.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom)") [setCompoundDrawablesRelativeWithIntrinsicBounds](https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setCompoundDrawablesRelativeWithIntrinsicBounds(android.widget.TextView,int,int,int,int))( textView: https://developer.android.com/reference/android/widget/TextView.html, start: @https://developer.android.com/reference/kotlin/androidx/annotation/DrawableRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, top: @https://developer.android.com/reference/kotlin/androidx/annotation/DrawableRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, end: @https://developer.android.com/reference/kotlin/androidx/annotation/DrawableRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, bottom: @https://developer.android.com/reference/kotlin/androidx/annotation/DrawableRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` **This function is deprecated.** Call setCompoundDrawablesRelativeWithIntrinsicBounds directly. <br /> |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/ReplaceWith(expression = "textView.setCustomSelectionActionModeCallback(callback)") [setCustomSelectionActionModeCallback](https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setCustomSelectionActionModeCallback(android.widget.TextView,android.view.ActionMode.Callback))( textView: https://developer.android.com/reference/android/widget/TextView.html, callback: https://developer.android.com/reference/android/view/ActionMode.Callback.html )` **This function is deprecated.** Call `https://developer.android.com/reference/android/widget/TextView.html#setCustomSelectionActionModeCallback(android.view.ActionMode.Callback)` directly. <br /> |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setFirstBaselineToTopHeight(android.widget.TextView,int)( textView: https://developer.android.com/reference/android/widget/TextView.html, firstBaselineToTopHeight: @https://developer.android.com/reference/kotlin/androidx/annotation/Px @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` 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. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setLastBaselineToBottomHeight(android.widget.TextView,int)( textView: https://developer.android.com/reference/android/widget/TextView.html, lastBaselineToBottomHeight: @https://developer.android.com/reference/kotlin/androidx/annotation/Px @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` 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. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setLineHeight(android.widget.TextView,int)(textView: https://developer.android.com/reference/android/widget/TextView.html, lineHeight: @https://developer.android.com/reference/kotlin/androidx/annotation/Px @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets an explicit line height for this TextView. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setLineHeight(android.widget.TextView,int,float)( textView: https://developer.android.com/reference/android/widget/TextView.html, unit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, lineHeight: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Sets an explicit line height to a given unit and value for the TextView. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setPrecomputedText(android.widget.TextView,androidx.core.text.PrecomputedTextCompat)( textView: https://developer.android.com/reference/android/widget/TextView.html, precomputed: https://developer.android.com/reference/kotlin/androidx/core/text/PrecomputedTextCompat )` Sets the PrecomputedTextCompat to the TextView If the given PrecomputeTextCompat is not compatible with textView, throws an IllegalArgumentException. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setTextAppearance(android.widget.TextView,int)(textView: https://developer.android.com/reference/android/widget/TextView.html, resId: @https://developer.android.com/reference/kotlin/androidx/annotation/StyleRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the text appearance from the specified style resource. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setTextMetricsParams(android.widget.TextView,androidx.core.text.PrecomputedTextCompat.Params)( textView: https://developer.android.com/reference/android/widget/TextView.html, params: https://developer.android.com/reference/kotlin/androidx/core/text/PrecomputedTextCompat.Params )` Apply the text layout parameter. |

## Constants

### AUTO_SIZE_TEXT_TYPE_NONE

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
const val AUTO_SIZE_TEXT_TYPE_NONE = 0: Int
```

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

### AUTO_SIZE_TEXT_TYPE_UNIFORM

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
const val AUTO_SIZE_TEXT_TYPE_UNIFORM = 1: Int
```

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

## Public functions

### getAutoSizeMaxTextSize

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun getAutoSizeMaxTextSize(textView: TextView): Int
```

name android:autoSizeMaxTextSize

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the current auto-size maximum text size in pixels (the default is 112sp). Note that if auto-size has not been configured this function returns `-1`. |

### getAutoSizeMinTextSize

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun getAutoSizeMinTextSize(textView: TextView): Int
```

name android:autoSizeMinTextSize

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the current auto-size minimum text size in pixels (the default is 12sp). Note that if auto-size has not been configured this function returns `-1`. |

### getAutoSizeStepGranularity

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun getAutoSizeStepGranularity(textView: TextView): Int
```

name android:autoSizeStepGranularity

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the current auto-size step granularity in pixels. |

### getAutoSizeTextAvailableSizes

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun getAutoSizeTextAvailableSizes(textView: TextView): Array<Int>
```

name android:autoSizePresetSizes

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>` | the current auto-size `int` sizes array (in pixels). |

### getAutoSizeTextType

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun getAutoSizeTextType(textView: TextView): Int
```

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

name android:autoSizeTextType

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | an `int` corresponding to one of the auto-size types: `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#AUTO_SIZE_TEXT_TYPE_NONE()` or `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#AUTO_SIZE_TEXT_TYPE_UNIFORM()` |

### getCompoundDrawableTintList

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun getCompoundDrawableTintList(textView: TextView): ColorStateList?
```

Return the tint applied to any compound drawables.

Only returns meaningful info when running on API v24 or newer, or if `textView` implements the `TintableCompoundDrawablesView` interface.

### getCompoundDrawableTintMode

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun getCompoundDrawableTintMode(textView: TextView): PorterDuff.Mode?
```

Return the tint mode applied to any compound drawables.

Only returns meaningful info when running on API v24 or newer, or if `textView` implements the `TintableCompoundDrawablesView` interface.

### getCompoundDrawablesRelative

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.15.0](https://developer.android.com/jetpack/androidx/releases/core#1.15.0)

```
@ReplaceWith(expression = "textView.getCompoundDrawablesRelative()")
java-static fun [getCompoundDrawablesRelative](https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#getCompoundDrawablesRelative(android.widget.TextView))(textView: TextView): Array<Drawable!>
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Call `https://developer.android.com/reference/android/widget/TextView.html#getCompoundDrawablesRelative()` directly.

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

### getFirstBaselineToTopHeight

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun getFirstBaselineToTopHeight(textView: TextView): Int
```

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

name android:firstBaselineToTopHeight

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setFirstBaselineToTopHeight(android.widget.TextView,int)` |   |

### getLastBaselineToBottomHeight

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun getLastBaselineToBottomHeight(textView: TextView): Int
```

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

name android:lastBaselineToBottomHeight

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setLastBaselineToBottomHeight(android.widget.TextView,int)` |   |

### getMaxLines

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.15.0](https://developer.android.com/jetpack/androidx/releases/core#1.15.0)

```
@ReplaceWith(expression = "textView.getMaxLines()")
java-static fun [getMaxLines](https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#getMaxLines(android.widget.TextView))(textView: TextView): Int
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Call `https://developer.android.com/reference/android/widget/TextView.html#getMaxLines()` directly.

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

### getMinLines

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.15.0](https://developer.android.com/jetpack/androidx/releases/core#1.15.0)

```
@ReplaceWith(expression = "textView.getMinLines()")
java-static fun [getMinLines](https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#getMinLines(android.widget.TextView))(textView: TextView): Int
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Call `https://developer.android.com/reference/android/widget/TextView.html#getMinLines()` directly.

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

### getTextMetricsParams

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun getTextMetricsParams(textView: TextView): PrecomputedTextCompat.Params
```

Gets the parameters for text layout precomputation, for use with `https://developer.android.com/reference/kotlin/androidx/core/text/PrecomputedTextCompat`.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/text/PrecomputedTextCompat.Params` | a current `https://developer.android.com/reference/kotlin/androidx/core/text/PrecomputedTextCompat.Params` |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/text/PrecomputedTextCompat` |   |

### setAutoSizeTextTypeUniformWithConfiguration

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun setAutoSizeTextTypeUniformWithConfiguration(
    textView: TextView,
    autoSizeMinTextSize: Int,
    autoSizeMaxTextSize: Int,
    autoSizeStepGranularity: Int,
    unit: Int
): Unit
```

Specify whether this widget should automatically scale the text to try to perfectly fit within the layout bounds. If all the configuration params are valid the type of auto-size is set to `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#AUTO_SIZE_TEXT_TYPE_UNIFORM()`.

name android:autoSizeTextType

name android:autoSizeTextType

name android:autoSizeMinTextSize

name android:autoSizeMaxTextSize

name android:autoSizeStepGranularity

| Parameters |
|---|---|
| `textView: https://developer.android.com/reference/android/widget/TextView.html` | TextView for which to set the mode. |
| `autoSizeMinTextSize: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the minimum text size available for auto-size |
| `autoSizeMaxTextSize: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the maximum text size available for auto-size |
| `autoSizeStepGranularity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the auto-size step granularity. It is used in conjunction with the minimum and maximum text size in order to build the set of text sizes the system uses to choose from when auto-sizing |
| `unit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the desired dimension unit for all sizes above. See `https://developer.android.com/reference/android/util/TypedValue.html` for the possible dimension units |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if any of the configuration params are invalid. |

### setAutoSizeTextTypeUniformWithPresetSizes

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun setAutoSizeTextTypeUniformWithPresetSizes(
    textView: TextView,
    presetSizes: IntArray<Int>,
    unit: Int
): Unit
```

Specify whether this widget should automatically scale the text to try to perfectly fit within the layout bounds. If at least one value from the `presetSizes` is valid then the type of auto-size is set to `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#AUTO_SIZE_TEXT_TYPE_UNIFORM()`.

name android:autoSizeTextType

name android:autoSizePresetSizes

| Parameters |
|---|---|
| `textView: https://developer.android.com/reference/android/widget/TextView.html` | TextView for which to set the mode. |
| `presetSizes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>` | an `int` array of sizes in pixels |
| `unit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the desired dimension unit for the preset sizes above. See `https://developer.android.com/reference/android/util/TypedValue.html` for the possible dimension units |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if all of the `presetSizes` are invalid. _ |

### setAutoSizeTextTypeWithDefaults

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun setAutoSizeTextTypeWithDefaults(
    textView: TextView,
    autoSizeTextType: Int
): Unit
```

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.

name android:autoSizeTextType

| Parameters |
|---|---|
| `textView: https://developer.android.com/reference/android/widget/TextView.html` | TextView for which to set the mode. |
| `autoSizeTextType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the type of auto-size. Must be one of `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#AUTO_SIZE_TEXT_TYPE_NONE()` or `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#AUTO_SIZE_TEXT_TYPE_UNIFORM()` |

### setCompoundDrawableTintList

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun setCompoundDrawableTintList(textView: TextView, tint: ColorStateList?): Unit
```

Applies a tint to any compound drawables.

This will always take effect when running on API v24 or newer. When running on platforms previous to API v24, it will only take effect if `textView` implements the `TintableCompoundDrawablesView` interface.

### setCompoundDrawableTintMode

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun setCompoundDrawableTintMode(
    textView: TextView,
    tintMode: PorterDuff.Mode?
): Unit
```

Applies a tint mode to any compound drawables.

This will always take effect when running on API v24 or newer. When running on platforms previous to API v24, it will only take effect if `textView` implements the `TintableCompoundDrawablesView` interface.

### setCompoundDrawablesRelative

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.15.0](https://developer.android.com/jetpack/androidx/releases/core#1.15.0)

```
@ReplaceWith(expression = "textView.setCompoundDrawablesRelative(start, top, end, bottom)")
java-static fun [setCompoundDrawablesRelative](https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setCompoundDrawablesRelative(android.widget.TextView,android.graphics.drawable.Drawable,android.graphics.drawable.Drawable,android.graphics.drawable.Drawable,android.graphics.drawable.Drawable))(
    textView: TextView,
    start: Drawable?,
    top: Drawable?,
    end: Drawable?,
    bottom: Drawable?
): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Call setCompoundDrawablesRelative directly.

Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text. Use `null` if you do not want a Drawable there. The Drawables must already have had `https://developer.android.com/reference/android/graphics/drawable/Drawable.html#setBounds(android.graphics.Rect)` called.
Calling this method will overwrite any Drawables previously set using `https://developer.android.com/reference/android/widget/TextView.html#setCompoundDrawables(android.graphics.drawable.Drawable, android.graphics.drawable.Drawable, android.graphics.drawable.Drawable, android.graphics.drawable.Drawable)` or related methods.

name android:drawableStart

name android:drawableTop

name android:drawableEnd

name android:drawableBottom

| Parameters |
|---|---|
| `textView: https://developer.android.com/reference/android/widget/TextView.html` | The TextView against which to invoke the method. |
| `start: https://developer.android.com/reference/android/graphics/drawable/Drawable.html?` | position in pixels of the start bound |
| `top: https://developer.android.com/reference/android/graphics/drawable/Drawable.html?` | position in pixels of the top bound |
| `end: https://developer.android.com/reference/android/graphics/drawable/Drawable.html?` | position in pixels of the end bound |
| `bottom: https://developer.android.com/reference/android/graphics/drawable/Drawable.html?` | position in pixels of the bottom bound |

### setCompoundDrawablesRelativeWithIntrinsicBounds

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.15.0](https://developer.android.com/jetpack/androidx/releases/core#1.15.0)

```
@ReplaceWith(expression = "textView.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom)")
java-static fun [setCompoundDrawablesRelativeWithIntrinsicBounds](https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setCompoundDrawablesRelativeWithIntrinsicBounds(android.widget.TextView,android.graphics.drawable.Drawable,android.graphics.drawable.Drawable,android.graphics.drawable.Drawable,android.graphics.drawable.Drawable))(
    textView: TextView,
    start: Drawable?,
    top: Drawable?,
    end: Drawable?,
    bottom: Drawable?
): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Call setCompoundDrawablesRelativeWithIntrinsicBounds directly.

Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text. Use `null` if 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 `https://developer.android.com/reference/android/widget/TextView.html#setCompoundDrawables(android.graphics.drawable.Drawable, android.graphics.drawable.Drawable, android.graphics.drawable.Drawable, android.graphics.drawable.Drawable)` or related methods.

name android:drawableStart

name android:drawableTop

name android:drawableEnd

name android:drawableBottom

| Parameters |
|---|---|
| `textView: https://developer.android.com/reference/android/widget/TextView.html` | The TextView against which to invoke the method. |
| `start: https://developer.android.com/reference/android/graphics/drawable/Drawable.html?` | drawable to use at start |
| `top: https://developer.android.com/reference/android/graphics/drawable/Drawable.html?` | drawable to use at top |
| `end: https://developer.android.com/reference/android/graphics/drawable/Drawable.html?` | drawable to use at end |
| `bottom: https://developer.android.com/reference/android/graphics/drawable/Drawable.html?` | drawable to use at bottom |

### setCompoundDrawablesRelativeWithIntrinsicBounds

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.15.0](https://developer.android.com/jetpack/androidx/releases/core#1.15.0)

```
@ReplaceWith(expression = "textView.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom)")
java-static fun [setCompoundDrawablesRelativeWithIntrinsicBounds](https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setCompoundDrawablesRelativeWithIntrinsicBounds(android.widget.TextView,int,int,int,int))(
    textView: TextView,
    start: @DrawableRes Int,
    top: @DrawableRes Int,
    end: @DrawableRes Int,
    bottom: @DrawableRes Int
): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Call setCompoundDrawablesRelativeWithIntrinsicBounds directly.

Sets the Drawables (if any) to appear to the start of, above, to the end of, and below the text. Use 0 if 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 `https://developer.android.com/reference/android/widget/TextView.html#setCompoundDrawables(android.graphics.drawable.Drawable, android.graphics.drawable.Drawable, android.graphics.drawable.Drawable, android.graphics.drawable.Drawable)` or related methods.

name android:drawableStart

name android:drawableTop

name android:drawableEnd

name android:drawableBottom

| Parameters |
|---|---|
| `textView: https://developer.android.com/reference/android/widget/TextView.html` | The TextView against which to invoke the method. |
| `start: @https://developer.android.com/reference/kotlin/androidx/annotation/DrawableRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Resource identifier of the start Drawable. |
| `top: @https://developer.android.com/reference/kotlin/androidx/annotation/DrawableRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Resource identifier of the top Drawable. |
| `end: @https://developer.android.com/reference/kotlin/androidx/annotation/DrawableRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Resource identifier of the end Drawable. |
| `bottom: @https://developer.android.com/reference/kotlin/androidx/annotation/DrawableRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Resource identifier of the bottom Drawable. |

### setCustomSelectionActionModeCallback

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.15.0](https://developer.android.com/jetpack/androidx/releases/core#1.15.0)

```
@ReplaceWith(expression = "textView.setCustomSelectionActionModeCallback(callback)")
java-static fun [setCustomSelectionActionModeCallback](https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#setCustomSelectionActionModeCallback(android.widget.TextView,android.view.ActionMode.Callback))(
    textView: TextView,
    callback: ActionMode.Callback
): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Call `https://developer.android.com/reference/android/widget/TextView.html#setCustomSelectionActionModeCallback(android.view.ActionMode.Callback)` directly.

Sets a selection action mode callback on a TextView. Also this method can be used to fix a bug in framework SDK 26/27. On these affected devices, the bug causes the menu containing the options for handling ACTION_PROCESS_TEXT after text selection to miss a number of items. This method can be used to fix this wrong behaviour for a text view, by passing any custom callback implementation. If no custom callback is desired, a no-op implementation should be provided. Note that, by default, the bug will only be fixed when the default floating toolbar menu implementation is used. If a custom implementation of `https://developer.android.com/reference/android/view/Menu.html` is provided, this should provide the method Menu#removeItemAt(int) which removes a menu item by its position, as given by Menu#getItem(int). Also, the following post condition should hold: a call to removeItemAt(i), should not modify the results of getItem(j) for any j [Menu](https://developer.android.com/reference/android/view/Menu.html) interface. However, it is required, and going to be called by reflection, in order to display the correct process text items in the menu.

| Parameters |
|---|---|
| `textView: https://developer.android.com/reference/android/widget/TextView.html` | The TextView to set the action selection mode callback on. |
| `callback: https://developer.android.com/reference/android/view/ActionMode.Callback.html` | The action selection mode callback to set on textView. |

### setFirstBaselineToTopHeight

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun setFirstBaselineToTopHeight(
    textView: TextView,
    firstBaselineToTopHeight: @Px @IntRange(from = 0) Int
): Unit
```

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. **Note** that if `FontMetrics.top` or `FontMetrics.ascent` was already greater than `firstBaselineToTopHeight`, the top padding is not updated.

name android:firstBaselineToTopHeight

| Parameters |
|---|---|
| `textView: https://developer.android.com/reference/android/widget/TextView.html` | TextView for which to set the padding. |
| `firstBaselineToTopHeight: @https://developer.android.com/reference/kotlin/androidx/annotation/Px @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | distance between first baseline to top of the container in pixels |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#getFirstBaselineToTopHeight(android.widget.TextView)` |   |
| `https://developer.android.com/reference/android/widget/TextView.html#setPadding(int, int, int, int)` |   |
| `https://developer.android.com/reference/android/widget/TextView.html#setPaddingRelative(int, int, int, int)` |   |

### setLastBaselineToBottomHeight

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun setLastBaselineToBottomHeight(
    textView: TextView,
    lastBaselineToBottomHeight: @Px @IntRange(from = 0) Int
): Unit
```

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. **Note** that if `FontMetrics.bottom` or `FontMetrics.descent` was already greater than `lastBaselineToBottomHeight`, the bottom padding is not updated.

name android:lastBaselineToBottomHeight

| Parameters |
|---|---|
| `textView: https://developer.android.com/reference/android/widget/TextView.html` | TextView for which to set the padding. |
| `lastBaselineToBottomHeight: @https://developer.android.com/reference/kotlin/androidx/annotation/Px @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | distance between last baseline to bottom of the container in pixels |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/widget/TextViewCompat#getLastBaselineToBottomHeight(android.widget.TextView)` |   |
| `https://developer.android.com/reference/android/widget/TextView.html#setPadding(int, int, int, int)` |   |
| `https://developer.android.com/reference/android/widget/TextView.html#setPaddingRelative(int, int, int, int)` |   |

### setLineHeight

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun setLineHeight(textView: TextView, lineHeight: @Px @IntRange(from = 0) Int): Unit
```

Sets an explicit line height for this TextView. This is equivalent to the vertical distance between subsequent baselines in the TextView.

name android:lineHeight

| Parameters |
|---|---|
| `textView: https://developer.android.com/reference/android/widget/TextView.html` | the TextView to modify |
| `lineHeight: @https://developer.android.com/reference/kotlin/androidx/annotation/Px @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the line height in pixels |

| See also |
|---|---|
| `https://developer.android.com/reference/android/widget/TextView.html#setLineSpacing(float, float)` |   |
| `https://developer.android.com/reference/android/widget/TextView.html#getLineSpacingExtra()` |   |
| `https://developer.android.com/reference/android/widget/TextView.html#getLineSpacingMultiplier()` |   |

### setLineHeight

Added in [1.12.0](https://developer.android.com/jetpack/androidx/releases/core#1.12.0)

```
java-static fun setLineHeight(
    textView: TextView,
    unit: Int,
    lineHeight: @FloatRange(from = 0) Float
): Unit
```

Sets an explicit line height to a given unit and value for the TextView. This is equivalent to the vertical distance between subsequent baselines in the TextView. See `https://developer.android.com/reference/android/util/TypedValue.html` for the possible dimension units.

ref android.R.styleable#TextView_lineHeight

| Parameters |
|---|---|
| `textView: https://developer.android.com/reference/android/widget/TextView.html` | the TextView to modify |
| `unit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | 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: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The desired line height in the given units. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/widget/TextView.html#setLineSpacing(float, float)` |   |
| `https://developer.android.com/reference/android/widget/TextView.html#getLineSpacingExtra()` |   |

### setPrecomputedText

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun setPrecomputedText(
    textView: TextView,
    precomputed: PrecomputedTextCompat
): Unit
```

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

| Parameters |
|---|---|
| `textView: https://developer.android.com/reference/android/widget/TextView.html` | the TextView |
| `precomputed: https://developer.android.com/reference/kotlin/androidx/core/text/PrecomputedTextCompat` | the precomputed text |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if precomputed text is not compatible with textView. |

### setTextAppearance

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun setTextAppearance(textView: TextView, resId: @StyleRes Int): Unit
```

Sets the text appearance from the specified style resource.

Use a framework-defined `TextAppearance` style like `https://developer.android.com/reference/android/R.style.html#TextAppearance_Material_Body1`.

| Parameters |
|---|---|
| `textView: https://developer.android.com/reference/android/widget/TextView.html` | The TextView against which to invoke the method. |
| `resId: @https://developer.android.com/reference/kotlin/androidx/annotation/StyleRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The resource identifier of the style to apply. |

### setTextMetricsParams

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun setTextMetricsParams(
    textView: TextView,
    params: PrecomputedTextCompat.Params
): Unit
```

Apply the text layout parameter. Update the TextView parameters to be compatible with `https://developer.android.com/reference/kotlin/androidx/core/text/PrecomputedTextCompat.Params`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/text/PrecomputedTextCompat` |   |