Button.Builder

Added in 1.1.0
Deprecated in 1.2.0

class Button.Builder : LayoutElementBuilders.LayoutElement.Builder


Builder class for Button.

Summary

Public constructors

Creates a builder for the Button from the given content.

Public functions

Button

Constructs and returns Button with the provided field and look.

Button.Builder

Sets the colors for the Button.

Button.Builder
setContentDescription(contentDescription: CharSequence)

Sets the content description for the Button.

Button.Builder

Sets the custom content for this Button.

Button.Builder
setIconContent(imageResourceId: String)

Sets the content of this Button to be the given icon with the default size that is half of the set size of the button.

Button.Builder
setIconContent(imageResourceId: String, size: DimensionBuilders.DpProp)

Sets the content of this Button to be the given icon with the given size.

Button.Builder
setImageContent(imageResourceId: String)

Sets the content of this Button to be the given image, i.e. contacts photo.

Button.Builder

Sets the size for the Button.

Button.Builder
setSize(size: @Dimension(unit = 0) Float)

Sets the size for the Button.

Button.Builder

Sets the content of this Button to be the given text with the default font for the set size (for the DEFAULT_SIZE, LARGE_SIZE and EXTRA_LARGE_SIZE is TYPOGRAPHY_TITLE2, TYPOGRAPHY_TITLE1 and TYPOGRAPHY_DISPLAY3 respectively).

Button.Builder
setTextContent(text: String, typographyName: Int)

Sets the content of this Button to be the given text with the given font.

Public constructors

Builder

Added in 1.1.0
Deprecated in 1.2.0
Builder(context: Context, clickable: ModifiersBuilders.Clickable)

Creates a builder for the Button from the given content. Custom content should be later set with one of the following (setIconContent, setTextContent, setImageContent.

Parameters
context: Context

The application's context.

clickable: ModifiersBuilders.Clickable

Associated androidx.wear.tiles.ModifiersBuilders.Clickable for click events. When the Button is clicked it will fire the associated action.

Public functions

build

Added in 1.1.0
Deprecated in 1.2.0
fun build(): Button

Constructs and returns Button with the provided field and look.

setButtonColors

Added in 1.1.0
Deprecated in 1.2.0
fun setButtonColors(buttonColors: ButtonColors): Button.Builder

Sets the colors for the Button. If not set, PRIMARY_COLORS will be used.

setContentDescription

Added in 1.1.0
Deprecated in 1.2.0
fun setContentDescription(contentDescription: CharSequence): Button.Builder

Sets the content description for the Button. It is highly recommended to provide this for button containing icon or image.

setCustomContent

Added in 1.1.0
Deprecated in 1.2.0
fun setCustomContent(content: LayoutElementBuilders.LayoutElement): Button.Builder

Sets the custom content for this Button. Any previously added content will be overridden.

setIconContent

Added in 1.1.0
Deprecated in 1.2.0
fun setIconContent(imageResourceId: String): Button.Builder

Sets the content of this Button to be the given icon with the default size that is half of the set size of the button. Any previously added content will be overridden. Provided icon will be tinted to the given content color from ButtonColors. This icon should be image with chosen alpha channel and not an actual image.

setIconContent

Added in 1.1.0
Deprecated in 1.2.0
fun setIconContent(imageResourceId: String, size: DimensionBuilders.DpProp): Button.Builder

Sets the content of this Button to be the given icon with the given size. Any previously added content will be overridden. Provided icon will be tinted to the given content color from ButtonColors and with the given size. This icon should be image with chosen alpha channel and not an actual image.

setImageContent

Added in 1.1.0
Deprecated in 1.2.0
fun setImageContent(imageResourceId: String): Button.Builder

Sets the content of this Button to be the given image, i.e. contacts photo. Any previously added content will be overridden.

setSize

Added in 1.1.0
Deprecated in 1.2.0
fun setSize(size: DimensionBuilders.DpProp): Button.Builder

Sets the size for the Button. Strongly recommended values are DEFAULT_SIZE, LARGE_SIZE and EXTRA_LARGE_SIZE. If not set, DEFAULT_SIZE will be used.

setSize

Added in 1.1.0
Deprecated in 1.2.0
fun setSize(size: @Dimension(unit = 0) Float): Button.Builder

Sets the size for the Button. Strongly recommended values are DEFAULT_SIZE, LARGE_SIZE and EXTRA_LARGE_SIZE. If not set, DEFAULT_SIZE will be used.

setTextContent

Added in 1.1.0
Deprecated in 1.2.0
fun setTextContent(text: String): Button.Builder

Sets the content of this Button to be the given text with the default font for the set size (for the DEFAULT_SIZE, LARGE_SIZE and EXTRA_LARGE_SIZE is TYPOGRAPHY_TITLE2, TYPOGRAPHY_TITLE1 and TYPOGRAPHY_DISPLAY3 respectively). Any previously added content will be overridden. Text should contain no more than 3 characters, otherwise it will overflow from the edges.

setTextContent

Added in 1.1.0
Deprecated in 1.2.0
fun setTextContent(text: String, typographyName: Int): Button.Builder

Sets the content of this Button to be the given text with the given font. If you need more font related customization, consider using setCustomContent with component. Any previously added content will be overridden. Text should contain no more than 3 characters, otherwise it will overflow from the edges.