AppCompatTextView
class AppCompatTextView : TextView, TintableBackgroundView, TintableCompoundDrawablesView, EmojiCompatConfigurationView
| kotlin.Any | |||
| ↳ | android.view.View | ||
| ↳ | android.widget.TextView | ||
| ↳ | androidx.appcompat.widget.AppCompatTextView |
EmojiAppCompatTextView |
AppCompatTextView widget enhanced with emoji capability by using |
A TextView which supports compatible features on older versions of the platform, including:
- Allows dynamic tint of its background via the background tint methods in
androidx.core.view.ViewCompat. - Allows setting of the background tint using
backgroundTintandbackgroundTintMode. - Supports auto-sizing via
androidx.core.widget.TextViewCompatby allowing to instruct aTextViewto let the size of the text expand or contract automatically to fill its layout based on the TextView's characteristics and boundaries. The style attributes associated with auto-sizing areautoSizeTextType,autoSizeMinTextSize,autoSizeMaxTextSize,autoSizeStepGranularityandautoSizePresetSizes, all of which work back toIce Cream Sandwich.
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(context: Context) |
AppCompatTextView(context: Context, attrs: AttributeSet?) |
AppCompatTextView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) |
Protected functions |
|
|---|---|
Unit |
|
Unit |
|
Unit |
|
Unit |
|
Unit |
onTextChanged( |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
AppCompatTextView
AppCompatTextView(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
Public functions
getCustomSelectionActionModeCallback
fun getCustomSelectionActionModeCallback(): ActionMode.Callback?
getTextClassifier
@RequiresApi(api = 26)
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
fun getTextMetricsParamsCompat(): PrecomputedTextCompat.Params
Gets the parameters for text layout precomputation, for use with PrecomputedTextCompat.
| Returns | |
|---|---|
PrecomputedTextCompat.Params |
a current |
| See also | |
|---|---|
PrecomputedTextCompat |
isEmojiCompatEnabled
fun isEmojiCompatEnabled(): Boolean
| Returns | |
|---|---|
Boolean |
the current enabled state, set via |
setCompoundDrawables
fun setCompoundDrawables(
left: Drawable?,
top: Drawable?,
right: Drawable?,
bottom: Drawable?
): Unit
setCompoundDrawablesRelative
fun setCompoundDrawablesRelative(
start: Drawable?,
top: Drawable?,
end: Drawable?,
bottom: Drawable?
): Unit
setCompoundDrawablesRelativeWithIntrinsicBounds
fun setCompoundDrawablesRelativeWithIntrinsicBounds(
start: Drawable?,
top: Drawable?,
end: Drawable?,
bottom: Drawable?
): Unit
setCompoundDrawablesRelativeWithIntrinsicBounds
fun setCompoundDrawablesRelativeWithIntrinsicBounds(
start: Int,
top: Int,
end: Int,
bottom: Int
): Unit
setCompoundDrawablesWithIntrinsicBounds
fun setCompoundDrawablesWithIntrinsicBounds(
left: Drawable?,
top: Drawable?,
right: Drawable?,
bottom: Drawable?
): Unit
setCompoundDrawablesWithIntrinsicBounds
fun setCompoundDrawablesWithIntrinsicBounds(
left: Int,
top: Int,
right: Int,
bottom: Int
): Unit
setCustomSelectionActionModeCallback
fun setCustomSelectionActionModeCallback(
actionModeCallback: ActionMode.Callback?
): Unit
setEmojiCompatEnabled
fun setEmojiCompatEnabled(enabled: Boolean): Unit
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 | |
|---|---|
enabled: Boolean |
if true, display missing emoji using EmojiCompat, otherwise display missing emoji using a fallback glyph "□" (known as tofu) |
setFirstBaselineToTopHeight
fun setFirstBaselineToTopHeight(
firstBaselineToTopHeight: @Px @IntRange(from = 0) Int
): Unit
setLastBaselineToBottomHeight
fun setLastBaselineToBottomHeight(
lastBaselineToBottomHeight: @Px @IntRange(from = 0) Int
): Unit
setPrecomputedText
fun setPrecomputedText(precomputed: PrecomputedTextCompat): Unit
Sets the PrecomputedTextCompat to the TextView. If the given PrecomputeTextCompat is not compatible with textView, throws an IllegalArgumentException.
| Parameters | |
|---|---|
precomputed: PrecomputedTextCompat |
the precomputed text |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if precomputed text is not compatible with textView. |
setTextClassifier
@RequiresApi(api = 26)
fun setTextClassifier(textClassifier: TextClassifier?): Unit
Sets the TextClassifier for this TextView.
setTextFuture
fun setTextFuture(future: Future<PrecomputedTextCompat!>?): Unit
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 | |
|---|---|
future: Future<PrecomputedTextCompat!>? |
a future for the precomputed text |
| See also | |
|---|---|
getTextFuture |
setTextMetricsParamsCompat
fun setTextMetricsParamsCompat(params: PrecomputedTextCompat.Params): Unit
Apply the text layout parameter. Update the TextView parameters to be compatible with PrecomputedTextCompat.Params.
| See also | |
|---|---|
PrecomputedTextCompat |
Protected functions
onLayout
protected fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int): Unit
onTextChanged
protected fun onTextChanged(
text: CharSequence!,
start: Int,
lengthBefore: Int,
lengthAfter: Int
): Unit