Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

AppCompatButton

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

A Button 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 R.attr#backgroundTint and R.attr#backgroundTintMode.

This will automatically be used when you use Button 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>(context: Context!)

<init>(context: Context!, attrs: AttributeSet!)

<init>(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

Public methods

open Unit

open Unit

open Unit

open Unit
setBackgroundResource(@DrawableRes resId: Int)

open Unit

See TextViewCompat#setCustomSelectionActionModeCallback(TextView, ActionMode.Callback)

open Unit

Sets the properties of this field to transform input to ALL CAPS display.

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

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

Protected methods

open Unit

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

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

Public constructors

<init>

AppCompatButton(context: Context!)

<init>

AppCompatButton(context: Context!, attrs: AttributeSet!)

<init>

AppCompatButton(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

Public methods

onInitializeAccessibilityEvent

open fun onInitializeAccessibilityEvent(event: AccessibilityEvent!): Unit

onInitializeAccessibilityNodeInfo

open fun onInitializeAccessibilityNodeInfo(info: AccessibilityNodeInfo!): Unit

setBackgroundDrawable

open fun setBackgroundDrawable(background: Drawable!): Unit

setBackgroundResource

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

setCustomSelectionActionModeCallback

open fun setCustomSelectionActionModeCallback(actionModeCallback: Callback!): Unit

See TextViewCompat#setCustomSelectionActionModeCallback(TextView, ActionMode.Callback)

setSupportAllCaps

open fun setSupportAllCaps(allCaps: Boolean): Unit

Sets the properties of this field to transform input to ALL CAPS display. This may use a "small caps" formatting if available. This setting will be ignored if this field is editable or selectable. This call replaces the current transformation method. Disabling this will not necessarily restore the previous behavior from before this was enabled.

setTextAppearance

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

setTextSize

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

Protected methods

drawableStateChanged

protected open fun drawableStateChanged(): Unit

onLayout

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

onTextChanged

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