public class Button implements LayoutElementBuilders.LayoutElement


ProtoLayout component Button that represents clickable button with the given content.

The Button is circular in shape. The recommended sizes are defined in ButtonDefaults.

The recommended set of ButtonColors styles can be obtained from ., e.g. PRIMARY_COLORS to get a color scheme for a primary Button.

When accessing the contents of a container for testing, note that this element can't be simply casted back to the original type, i.e.:

Button button = new Button...
Box box = new Box.Builder().addContent(button).build();

Button myButton = (Button) box.getContents().get(0);
will fail.

To be able to get Button object from any layout element, fromLayoutElement method should be used, i.e.:

Button myButton = Button.fromLayoutElement(box.getContents().get(0));

Summary

Nested types

public final class Button.Builder

Builder class for Button.

Public methods

static @Nullable Button

Returns Button object from the given LayoutElement (e.g. one retrieved from a container's content with container.getContents().get(index)) if that element can be converted to Button.

@NonNull ButtonColors

Returns button color of this Button.

@NonNull ModifiersBuilders.Clickable

Returns click event action associated with this Button.

@Nullable TypeBuilders.StringProp

Returns content description for this Button.

@Nullable LayoutElementBuilders.LayoutElement

Returns the custom content of this Button if it has been added.

@Nullable String

Returns the icon content of this Button if it has been added.

@Nullable String

Returns the image content of this Button if it has been added.

@NonNull DimensionBuilders.ContainerDimension

Returns size for this Button.

@Nullable String

Returns the text content of this Button if it has been added.

Public methods

fromLayoutElement

Added in 1.0.0
public static @Nullable Button fromLayoutElement(@NonNull LayoutElementBuilders.LayoutElement element)

Returns Button object from the given LayoutElement (e.g. one retrieved from a container's content with container.getContents().get(index)) if that element can be converted to Button. Otherwise, it will return null.

getButtonColors

Added in 1.0.0
public @NonNull ButtonColors getButtonColors()

Returns button color of this Button.

Note that the content color will be unset if the content of this Button is an image.

getClickable

Added in 1.0.0
public @NonNull ModifiersBuilders.Clickable getClickable()

Returns click event action associated with this Button.

getContentDescription

Added in 1.0.0
public @Nullable TypeBuilders.StringProp getContentDescription()

Returns content description for this Button.

getCustomContent

Added in 1.0.0
public @Nullable LayoutElementBuilders.LayoutElement getCustomContent()

Returns the custom content of this Button if it has been added. Otherwise, it returns null.

getIconContent

Added in 1.0.0
public @Nullable String getIconContent()

Returns the icon content of this Button if it has been added. Otherwise, it returns null.

getImageContent

Added in 1.0.0
public @Nullable String getImageContent()

Returns the image content of this Button if it has been added. Otherwise, it returns null.

getSize

Added in 1.0.0
public @NonNull DimensionBuilders.ContainerDimension getSize()

Returns size for this Button.

getTextContent

Added in 1.0.0
public @Nullable String getTextContent()

Returns the text content of this Button if it has been added. Otherwise, it returns null.