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
The display context.
The attribute set provided in the layout XML file.
Constructors
Constructor that is called when inflating the control from XML.
Types
Properties
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.
The color of the badge. This color is not applied for the stroke around the badge. The default value is Color.WHITE.
The radius of the badge corner in pixels. The default value is 0
.
The width of the stroke around the badge in pixels. The default value is 0
.
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.
The tint used to modify the color of ttDrawable when ttDrawableTintMatchesTextColor is 'false'.
Matches the drawable color with the text color when set to true
. The default value is false
.
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.
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
.
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.
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
Overridden method because TextView's calculation of the compound left padding always includes the android:drawablePadding, even if the text itself is empty.
Overridden method because TextView's calculation of the compound right padding always includes the android:drawablePadding, even if the text itself is empty.
Set the button text from the given stringResolver.
Set ttDrawable by the given drawableResolver.