TtButton

A reusable button control that implements the different visual states.

There are several different types of buttons that can be used. Changing the type changes the button's appearance, elevation, text color, background etc.

The client can also specify :

  • a Drawable if a button needs an additional drawable element.

  • start and end padding if a button needs different spacing than global one used for all buttons.

Showing the badge on the top of the button's drawable is also possible. A typical use case could be: e.g. inform the user multiple events have happened.

All theme attributes used by this control are declared in com.tomtom.tools.android.core.theme. To use this control, it is mandatory to define these attribute values.

Parameters

context

The display context.

attrs

The attribute set provided in the layout XML file.

Constructors

Link copied to clipboard
constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = CoreThemeR.attr.tt_button_style)

Constructor that is called when inflating the control from XML.

Types

Link copied to clipboard

The action type of a button. It affects the appearance of the button, e.g. text color, background.

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The action type of the button. The appearance of the button is selected based upon the specified action type. The default type is ActionType.PRIMARY.

Link copied to clipboard

The color of the badge. This color is not applied for the stroke around the badge. The default value is Color.WHITE.

Link copied to clipboard

The radius of the badge corner in pixels. The default value is 0.

Link copied to clipboard

The width of the stroke around the badge in pixels. The default value is 0.

Link copied to clipboard

The drawable shown at the start of the button. A button can have the combination of a drawable and a text to indicate users what action the button provides.

Link copied to clipboard

The tint used to modify the color of ttDrawable when ttDrawableTintMatchesTextColor is 'false'.

Link copied to clipboard

Matches the drawable color with the text color when set to true. The default value is false.

Link copied to clipboard

The desired size of ttDrawable. If ttDrawable has unequal width and height, its aspect ratio will be kept. Use 0 to use source Drawable size.

Link copied to clipboard

Showing the badge on the top of ttDrawable when set to true. A typical use case would be: e.g. to inform the user that multiple events have happened. The default value is false.

Link copied to clipboard

The end padding in Px which can be changed via style for single button. Property is used over theme dimension i.e. tt_button_padding_textonly_horizontal. If set to NO_CUSTOM_PADDING, theme dimensions are used by default.

Link copied to clipboard

The start padding in Px which can be changed via style for single button. Property is used over theme dimension i.e. tt_button_padding_textonly_horizontal. If set to NO_CUSTOM_PADDING, theme dimensions are used by default.

Functions

Link copied to clipboard
open override fun getCompoundPaddingLeft(): Int

Overridden method because TextView's calculation of the compound left padding always includes the android:drawablePadding, even if the text itself is empty.

Link copied to clipboard
open override fun getCompoundPaddingRight(): Int

Overridden method because TextView's calculation of the compound right padding always includes the android:drawablePadding, even if the text itself is empty.

Link copied to clipboard
open override fun onTouchEvent(event: MotionEvent?): Boolean
Link copied to clipboard
open override fun setActivated(activated: Boolean)
Link copied to clipboard
open override fun setPadding(left: Int, top: Int, right: Int, bottom: Int)
Link copied to clipboard
open override fun setPaddingRelative(start: Int, top: Int, end: Int, bottom: Int)
Link copied to clipboard
fun setText(stringResolver: StringResolver?)

Set the button text from the given stringResolver.

Link copied to clipboard
fun setTtDrawable(drawableResolver: DrawableResolver?)

Set ttDrawable by the given drawableResolver.

Inherited functions

Link copied to clipboard
Link copied to clipboard
open fun addFocusables(p0: ArrayList<View>, p1: Int)
open fun addFocusables(p0: ArrayList<View>, p1: Int, p2: Int)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun append(p0: CharSequence, p1: Int, p2: Int)
Link copied to clipboard
open override fun autofill(p0: AutofillValue)
Link copied to clipboard
open fun beginBatchEdit()
Link copied to clipboard
Link copied to clipboard
open fun bringToFront()
Link copied to clipboard
Link copied to clipboard
open fun buildLayer()
Link copied to clipboard
open fun callOnClick(): Boolean
Link copied to clipboard
Link copied to clipboard
open override fun cancelLongPress()
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun clearAnimation()
Link copied to clipboard
Link copied to clipboard
open fun clearFocus()
Link copied to clipboard
Link copied to clipboard
open override fun computeScroll()
Link copied to clipboard
Link copied to clipboard
open fun debug(p0: Int)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun dispatchDisplayHint(p0: Int)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun dispatchNestedFling(p0: Float, p1: Float, p2: Boolean): Boolean
Link copied to clipboard
Link copied to clipboard
open fun dispatchNestedPreScroll(p0: Int, p1: Int, p2: IntArray?, p3: IntArray?): Boolean
Link copied to clipboard
open fun dispatchNestedScroll(p0: Int, p1: Int, p2: Int, p3: Int, p4: IntArray?): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun draw(p0: Canvas)
Link copied to clipboard
open override fun drawableHotspotChanged(p0: Float, p1: Float)
Link copied to clipboard
open fun endBatchEdit()
Link copied to clipboard
Link copied to clipboard
open fun findFocus(): View
Link copied to clipboard
fun <T : View> findViewById(p0: Int): T
Link copied to clipboard
open override fun findViewsWithText(p0: ArrayList<View>, p1: CharSequence, p2: Int)
Link copied to clipboard
fun <T : View> findViewWithTag(p0: Any): T
Link copied to clipboard
open fun focusSearch(p0: Int): View
Link copied to clipboard
Link copied to clipboard
open fun forceLayout()
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getAlpha(): Float
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun getAutofillHints(): Array<String>?
Link copied to clipboard
Link copied to clipboard
open override fun getAutofillType(): Int
Link copied to clipboard
open override fun getAutofillValue(): AutofillValue?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun getBaseline(): Int
Link copied to clipboard
fun getBottom(): Int
Link copied to clipboard
open fun getBreakStrategy(): Int
Link copied to clipboard
Link copied to clipboard
open fun getClipBounds(): Rect
open fun getClipBounds(p0: Rect): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getDisplay(): Display
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getDrawingRect(p0: Rect)
Link copied to clipboard
open fun getDrawingTime(): Long
Link copied to clipboard
Link copied to clipboard
open fun getElevation(): Float
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getExplicitStyle(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getFocusable(): Int
Link copied to clipboard
Link copied to clipboard
open override fun getFocusedRect(p0: Rect)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getGravity(): Int
Link copied to clipboard
open fun getHandler(): Handler
Link copied to clipboard
fun getHeight(): Int
Link copied to clipboard
Link copied to clipboard
open fun getHint(): CharSequence
Link copied to clipboard
Link copied to clipboard
open fun getHitRect(p0: Rect)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getId(): Int
Link copied to clipboard
open fun getImeActionId(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getImeOptions(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getInputType(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getLabelFor(): Int
Link copied to clipboard
Link copied to clipboard
open fun getLayerType(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun getLeft(): Int
Link copied to clipboard
Link copied to clipboard
open fun getLineBounds(p0: Int, p1: Rect): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getLineCount(): Int
Link copied to clipboard
open fun getLineHeight(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getMatrix(): Matrix
Link copied to clipboard
open fun getMaxEms(): Int
Link copied to clipboard
open fun getMaxHeight(): Int
Link copied to clipboard
open fun getMaxLines(): Int
Link copied to clipboard
open fun getMaxWidth(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getMinEms(): Int
Link copied to clipboard
open fun getMinHeight(): Int
Link copied to clipboard
open fun getMinimumHeight(): Int
Link copied to clipboard
open fun getMinimumWidth(): Int
Link copied to clipboard
open fun getMinLines(): Int
Link copied to clipboard
open fun getMinWidth(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getNextFocusUpId(): Int
Link copied to clipboard
open fun getOffsetForPosition(p0: Float, p1: Float): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getPaddingBottom(): Int
Link copied to clipboard
open fun getPaddingEnd(): Int
Link copied to clipboard
open fun getPaddingLeft(): Int
Link copied to clipboard
open fun getPaddingRight(): Int
Link copied to clipboard
open fun getPaddingStart(): Int
Link copied to clipboard
open fun getPaddingTop(): Int
Link copied to clipboard
open fun getPaint(): TextPaint
Link copied to clipboard
open fun getPaintFlags(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getPivotX(): Float
Link copied to clipboard
open fun getPivotY(): Float
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun getRight(): Int
Link copied to clipboard
open fun getRootView(): View
Link copied to clipboard
Link copied to clipboard
open fun getRotation(): Float
Link copied to clipboard
open fun getRotationX(): Float
Link copied to clipboard
open fun getRotationY(): Float
Link copied to clipboard
open fun getScaleX(): Float
Link copied to clipboard
open fun getScaleY(): Float
Link copied to clipboard
Link copied to clipboard
open fun getScrollBarSize(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getSelectionEnd(): Int
Link copied to clipboard
Link copied to clipboard
open fun getShadowColor(): Int
Link copied to clipboard
open fun getShadowDx(): Float
Link copied to clipboard
open fun getShadowDy(): Float
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getSolidColor(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getTag(): Any
open fun getTag(p0: Int): Any
Link copied to clipboard
open fun getText(): CharSequence
Link copied to clipboard
open fun getTextAlignment(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getTextDirection(): Int
Link copied to clipboard
open fun getTextLocale(): Locale
Link copied to clipboard
Link copied to clipboard
open fun getTextScaleX(): Float
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getTextSize(): Float
Link copied to clipboard
open fun getTextSizeUnit(): Int
Link copied to clipboard
Link copied to clipboard
fun getTop(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getTypeface(): Typeface
Link copied to clipboard
Link copied to clipboard
open fun getUrls(): Array<URLSpan>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getVisibility(): Int
Link copied to clipboard
fun getWidth(): Int
Link copied to clipboard
open fun getWindowId(): WindowId
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getX(): Float
Link copied to clipboard
open fun getY(): Float
Link copied to clipboard
open fun getZ(): Float
Link copied to clipboard
Link copied to clipboard
open fun hasFocus(): Boolean
Link copied to clipboard
open fun hasFocusable(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun hasOverlappingRendering(): Boolean
Link copied to clipboard
Link copied to clipboard
open fun hasSelection(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun invalidate()
open fun invalidate(p0: Rect)
open fun invalidate(p0: Int, p1: Int, p2: Int, p3: Int)
Link copied to clipboard
open override fun invalidateDrawable(p0: Drawable)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun isActivated(): Boolean
Link copied to clipboard
open fun isAllCaps(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun isClickable(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun isDirty(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun isEmojiCompatEnabled(): Boolean
Link copied to clipboard
open fun isEnabled(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun isFocused(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun isHovered(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun isInEditMode(): Boolean
Link copied to clipboard
open fun isInLayout(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun isLaidOut(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun isOpaque(): Boolean
Link copied to clipboard
Link copied to clipboard
open fun isPivotSet(): Boolean
Link copied to clipboard
Link copied to clipboard
open fun isPressed(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun isSelected(): Boolean
Link copied to clipboard
Link copied to clipboard
open fun isShown(): Boolean
Link copied to clipboard
open fun isSingleLine(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun jumpDrawablesToCurrentState()
Link copied to clipboard
Link copied to clipboard
open fun layout(p0: Int, p1: Int, p2: Int, p3: Int)
Link copied to clipboard
open fun length(): Int
Link copied to clipboard
fun measure(p0: Int, p1: Int)
Link copied to clipboard
Link copied to clipboard
open fun offsetLeftAndRight(p0: Int)
Link copied to clipboard
open fun offsetTopAndBottom(p0: Int)
Link copied to clipboard
Link copied to clipboard
open fun onBeginBatchEdit()
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun onCheckIsTextEditor(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun onDragEvent(p0: DragEvent): Boolean
Link copied to clipboard
open fun onDrawForeground(p0: Canvas)
Link copied to clipboard
open fun onEditorAction(p0: Int)
Link copied to clipboard
open fun onEndBatchEdit()
Link copied to clipboard
Link copied to clipboard
open override fun onGenericMotionEvent(p0: MotionEvent): Boolean
Link copied to clipboard
open fun onHoverChanged(p0: Boolean)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun onKeyDown(p0: Int, p1: KeyEvent): Boolean
Link copied to clipboard
open override fun onKeyLongPress(p0: Int, p1: KeyEvent): Boolean
Link copied to clipboard
open override fun onKeyMultiple(p0: Int, p1: Int, p2: KeyEvent): Boolean
Link copied to clipboard
open override fun onKeyPreIme(p0: Int, p1: KeyEvent): Boolean
Link copied to clipboard
open override fun onKeyShortcut(p0: Int, p1: KeyEvent): Boolean
Link copied to clipboard
open override fun onKeyUp(p0: Int, p1: KeyEvent): Boolean
Link copied to clipboard
Link copied to clipboard
open override fun onPreDraw(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun onReceiveContent(p0: ContentInfo): ContentInfo?
Link copied to clipboard
open override fun onResolvePointerIcon(p0: MotionEvent, p1: Int): PointerIcon
Link copied to clipboard
open override fun onRestoreInstanceState(p0: Parcelable)
Link copied to clipboard
open override fun onRtlPropertiesChanged(p0: Int)
Link copied to clipboard
open override fun onSaveInstanceState(): Parcelable?
Link copied to clipboard
open override fun onScreenStateChanged(p0: Int)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun onTrackballEvent(p0: MotionEvent): Boolean
Link copied to clipboard
open override fun onVisibilityAggregated(p0: Boolean)
Link copied to clipboard
open override fun onWindowFocusChanged(p0: Boolean)
Link copied to clipboard
Link copied to clipboard
open fun performClick(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun performLongClick(p0: Float, p1: Float): Boolean
open override fun performLongClick(): Boolean
Link copied to clipboard
Link copied to clipboard
open fun playSoundEffect(p0: Int)
Link copied to clipboard
open