public class MultiButtonLayout implements LayoutElementBuilders.LayoutElement


Opinionated ProtoLayout layout, that can contain between 1 and MAX_BUTTONS number of buttons arranged inline with the Material guidelines. Can be used as a content passed in to the PrimaryLayout, but if there is MAX_BUTTONS buttons it should be used on its own. Visuals and design samples can be found * here.

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.:

MultiButtonLayout mbl = new MultiButtonLayout...
Box box = new Box.Builder().addContent(mbl).build();

MultiButtonLayout myMbl = (MultiButtonLayout) box.getContents().get(0);
will fail.

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

MultiButtonLayout myMbl = MultiButtonLayout.fromLayoutElement(box.getContents().get(0));

Summary

Nested types

public final class MultiButtonLayout.Builder

Builder class for MultiButtonLayout.

Constants

static final int

Button distribution where the last row has more buttons than other rows.

static final int

Button distribution where the first row has more buttons than other rows.

Public methods

static @Nullable MultiButtonLayout

Returns MultiButtonLayout 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 MultiButtonLayout.

@NonNull List<LayoutElementBuilders.LayoutElement>

Gets the content from this layout, containing all buttons that were added.

int

Gets the button distribution from this layout for the case when there is 5 buttons in the layout.

Constants

FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY

Added in 1.0.0
public static final int FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY = 2

Button distribution where the last row has more buttons than other rows.

FIVE_BUTTON_DISTRIBUTION_TOP_HEAVY

Added in 1.0.0
public static final int FIVE_BUTTON_DISTRIBUTION_TOP_HEAVY = 1

Button distribution where the first row has more buttons than other rows.

Public methods

fromLayoutElement

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

Returns MultiButtonLayout 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 MultiButtonLayout. Otherwise, it will return null.

getButtonContents

Added in 1.0.0
public @NonNull List<LayoutElementBuilders.LayoutElementgetButtonContents()

Gets the content from this layout, containing all buttons that were added.

getFiveButtonDistribution

Added in 1.0.0
public int getFiveButtonDistribution()

Gets the button distribution from this layout for the case when there is 5 buttons in the layout. If there is more or less buttons than 5, default FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY will be returned.