MultiButtonLayout

Added in 1.1.0
Deprecated in 1.2.0

class MultiButtonLayout : LayoutElementBuilders.LayoutElement


Opinionated Tiles layout, that can contain between 1 and MULTI_BUTTON_MAX_NUMBER number of buttons arranged inline with the Material guidelines. Can be used as a content passed in to the PrimaryLayout, but if there is MULTI_BUTTON_MAX_NUMBER buttons it should be used on its own.

For additional examples and suggested layouts see Tiles Design System.

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

Constants

const Int

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

const Int

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

Public functions

java-static MultiButtonLayout?

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

(Mutable)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.1.0
Deprecated in 1.2.0
const val FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY = 2: Int

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

FIVE_BUTTON_DISTRIBUTION_TOP_HEAVY

Added in 1.1.0
Deprecated in 1.2.0
const val FIVE_BUTTON_DISTRIBUTION_TOP_HEAVY = 1: Int

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

Public functions

fromLayoutElement

Added in 1.1.0
Deprecated in 1.2.0
java-static fun fromLayoutElement(element: LayoutElementBuilders.LayoutElement): MultiButtonLayout?

Returns MultiButtonLayout object from the given androidx.wear.tiles.LayoutElementBuilders.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.1.0
Deprecated in 1.2.0
fun getButtonContents(): (Mutable)List<LayoutElementBuilders.LayoutElement!>

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

getFiveButtonDistribution

Added in 1.1.0
Deprecated in 1.2.0
fun getFiveButtonDistribution(): Int

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.