public final class

Button.Builder

extends java.lang.Object

implements LayoutElementBuilders.LayoutElement.Builder

 java.lang.Object

↳androidx.wear.tiles.material.Button.Builder

Overview

Builder class for Button.

Summary

Constructors
publicBuilder(Context context, ModifiersBuilders.Clickable clickable)

Creates a builder for the Button from the given content.

Methods
public Buttonbuild()

Constructs and returns Button with the provided field and look.

public Button.BuildersetButtonColors(ButtonColors buttonColors)

Sets the colors for the Button.

public Button.BuildersetContent(LayoutElementBuilders.LayoutElement content)

Sets the custom content for this Button.

public Button.BuildersetContentDescription(java.lang.CharSequence contentDescription)

Sets the content description for the Button.

public Button.BuildersetIconContent(java.lang.String resourceId)

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.

public Button.BuildersetIconContent(java.lang.String resourceId, DimensionBuilders.DpProp size)

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

public Button.BuildersetImageContent(java.lang.String resourceId)

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

public Button.BuildersetSize(DimensionBuilders.DpProp size)

Sets the size for the Button.

public Button.BuildersetSize(float size)

Sets the size for the Button.

public Button.BuildersetTextContent(java.lang.String text)

Sets the content of this Button to be the given text with the default font for the set size (for the ButtonDefaults.DEFAULT_BUTTON_SIZE, ButtonDefaults.LARGE_BUTTON_SIZE and ButtonDefaults.EXTRA_LARGE_BUTTON_SIZE is Typography.TYPOGRAPHY_TITLE2, Typography.TYPOGRAPHY_TITLE1 and Typography.TYPOGRAPHY_DISPLAY3 respectively).

public Button.BuildersetTextContent(java.lang.String text, int typographyName)

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

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder(Context context, ModifiersBuilders.Clickable clickable)

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

Parameters:

context: The application's context.
clickable: Associated ModifiersBuilders.Clickable for click events. When the Button is clicked it will fire the associated action.

Methods

public Button.Builder setContentDescription(java.lang.CharSequence contentDescription)

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

Sets the size for the Button. Strongly recommended values are ButtonDefaults.DEFAULT_BUTTON_SIZE, ButtonDefaults.LARGE_BUTTON_SIZE and ButtonDefaults.EXTRA_LARGE_BUTTON_SIZE. If not set, ButtonDefaults.DEFAULT_BUTTON_SIZE will be used.

public Button.Builder setSize(float size)

Sets the size for the Button. Strongly recommended values are ButtonDefaults.DEFAULT_BUTTON_SIZE, ButtonDefaults.LARGE_BUTTON_SIZE and ButtonDefaults.EXTRA_LARGE_BUTTON_SIZE. If not set, ButtonDefaults.DEFAULT_BUTTON_SIZE will be used.

public Button.Builder setButtonColors(ButtonColors buttonColors)

Sets the colors for the Button. If set, ButtonColors.getBackgroundColor() will be used for the background of the button. If not set, ButtonDefaults.PRIMARY_BUTTON_COLORS will be used.

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

public Button.Builder setIconContent(java.lang.String resourceId, DimensionBuilders.DpProp size)

Sets the content of this Button to be the given icon. 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.

public Button.Builder setIconContent(java.lang.String resourceId)

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.

public Button.Builder setTextContent(java.lang.String text)

Sets the content of this Button to be the given text with the default font for the set size (for the ButtonDefaults.DEFAULT_BUTTON_SIZE, ButtonDefaults.LARGE_BUTTON_SIZE and ButtonDefaults.EXTRA_LARGE_BUTTON_SIZE is Typography.TYPOGRAPHY_TITLE2, Typography.TYPOGRAPHY_TITLE1 and Typography.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.

public Button.Builder setTextContent(java.lang.String text, int typographyName)

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

public Button.Builder setImageContent(java.lang.String resourceId)

Sets the content of this Button to be the given icon with the default size that is half of the 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.

public Button build()

Constructs and returns Button with the provided field and look.