public final class

Button.Builder

extends java.lang.Object

implements LayoutElementBuilders.LayoutElement.Builder

 java.lang.Object

↳androidx.wear.protolayout.materialcore.Button.Builder

Overview

Builder class for Button.

Summary

Fields
public static final intCUSTOM_CONTENT

Button type to be used when setting a content which is a custom one.

public static final intICON

Button type to be used when setting a content which represents an icon.

public static final intIMAGE

Button type to be used when setting a content which represents an image.

public static final intNOT_SET

public static final intTEXT

Button type to be used when setting a content which represents a text.

Constructors
publicBuilder(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.BuildersetBackgroundColor(ColorBuilders.ColorProp backgroundColor)

Sets the background colors for the Button.

public Button.BuildersetContent(LayoutElementBuilders.LayoutElement content, int type)

Sets the content for this Button.

public Button.BuildersetContentDescription(TypeBuilders.StringProp contentDescription)

Sets the content description for the Button.

public Button.BuildersetSize(DimensionBuilders.DpProp size)

Sets the size for the Button.

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

Fields

public static final int NOT_SET

public static final int ICON

Button type to be used when setting a content which represents an icon.

public static final int TEXT

Button type to be used when setting a content which represents a text.

public static final int IMAGE

Button type to be used when setting a content which represents an image.

public static final int CUSTOM_CONTENT

Button type to be used when setting a content which is a custom one.

Constructors

public Builder(ModifiersBuilders.Clickable clickable)

Creates a builder for the Button from the given content. Custom content should be later set with (Button.Builder.setContent(LayoutElementBuilders.LayoutElement, int) and specifying the correct content type.

Parameters:

clickable: Associated ModifiersBuilders.Clickable for click events. When the Button is clicked it will fire the associated action.

Methods

public Button.Builder setContentDescription(TypeBuilders.StringProp contentDescription)

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

While this field is statically accessible from 1.0, it's only bindable since version 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).

Sets the size for the Button. If not set, Button won't be shown.

public Button.Builder setBackgroundColor(ColorBuilders.ColorProp backgroundColor)

Sets the background colors for the Button. If not set, black is used.

public Button.Builder setContent(LayoutElementBuilders.LayoutElement content, int type)

Sets the content for this Button. Any previously added content will be overridden. Provided content should be styled and sized.

public Button build()

Constructs and returns Button with the provided field and look.