MultiSlotLayout


public class MultiSlotLayout implements LayoutElementBuilders.LayoutElement


Opinionated ProtoLayout layout, row like style with horizontally aligned and spaced slots (for icons or other small content). Should be used as a content passed in to the . Visuals and design samples can be found here.

Recommended number of added slots is 1 to 3. Their width will be the width of an element passed in, with the MULTI_SLOT_LAYOUT_HORIZONTAL_SPACER_WIDTH space between.

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

MultiSlotLayout msl = new MultiSlotLayout...
Box box = new Box.Builder().addContent(msl).build();

MultiSlotLayout myMsl = (MultiSlotLayout) box.getContents().get(0);
will fail.

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

MultiSlotLayout myMsl = MultiSlotLayout.fromLayoutElement(box.getContents().get(0));

Summary

Nested types

public final class MultiSlotLayout.Builder

Builder class for MultiSlotLayout.

Public methods

static @Nullable MultiSlotLayout

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

@Dimension(unit = 0) float

Gets the width of horizontal spacer that is between slots.

@NonNull List<LayoutElementBuilders.LayoutElement>

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

Public methods

fromLayoutElement

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

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

getHorizontalSpacerWidth

Added in 1.0.0
public @Dimension(unit = 0) float getHorizontalSpacerWidth()

Gets the width of horizontal spacer that is between slots.

getSlotContents

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

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

Discover the latest app development tools, platform updates, training, and documentation for developers across every Android device.

Updated Nov 20, 2024

In this codelab, you integrate the Paging library into an app that shows a list. The Paging library helps you load and display pages of data from a larger dataset from local storage or over network.

Updated Dec 9, 2024

Explore the Android platform. Learn about the latest releases and technologies for creating Android apps.

Updated Jan 24, 2025