EdgeButtonKt

Added in 1.3.0-alpha06

public final class EdgeButtonKt


Summary

Public methods

static final @NonNull LayoutElementBuilders.LayoutElement

ProtoLayout Material3 component edge button that offers a single slot to take an icon or similar round, small content.

static final @NonNull LayoutElementBuilders.LayoutElement

ProtoLayout Material3 component edge button that offers a single slot to take a text or similar long and wide content.

Public methods

public static final @NonNull LayoutElementBuilders.LayoutElement iconEdgeButton(
    @NonNull MaterialScope receiver,
    @NonNull ModifiersBuilders.Clickable onClick,
    @NonNull LayoutModifier modifier,
    @NonNull ButtonColors colors,
    @ExtensionFunctionType @NonNull Function1<@NonNull MaterialScope, @NonNull LayoutElementBuilders.LayoutElement> iconContent
)

ProtoLayout Material3 component edge button that offers a single slot to take an icon or similar round, small content.

The edge button is intended to be used at the bottom of a round screen. It has a special shape with its bottom almost follows the screen's curvature. It has fixed height, and takes 1 line of text or a single icon. This button represents the most important action on the screen, and it must occupy the whole horizontal space in its position as well as being anchored to the screen bottom.

This component is not intended to be used with an image background.

import androidx.wear.protolayout.material3.button
import androidx.wear.protolayout.material3.icon
import androidx.wear.protolayout.material3.iconEdgeButton
import androidx.wear.protolayout.material3.materialScope
import androidx.wear.protolayout.material3.text
import androidx.wear.protolayout.modifiers.LayoutModifier
import androidx.wear.protolayout.modifiers.clickable
import androidx.wear.protolayout.modifiers.contentDescription

materialScope(context, deviceConfiguration) {
        iconEdgeButton(
            onClick = clickable,
            modifier = LayoutModifier.contentDescription("Description of a button")
        ) {
            icon(protoLayoutResourceId = "id")
        }
    }
Parameters
@NonNull ModifiersBuilders.Clickable onClick

Associated Clickable for click events. When the button is clicked it will fire the associated action.

@NonNull LayoutModifier modifier

Modifiers to set to this element. It's highly recommended to set a content description using contentDescription.

@NonNull ButtonColors colors

The colors used for this button. If not set, ButtonDefaults.filledButtonColors will be used as high emphasis button. Other recommended colors are ButtonDefaults.filledTonalButtonColors and ButtonDefaults.filledVariantButtonColors. If using custom colors, it is important to choose a color pair from same role to ensure accessibility with sufficient color contrast.

@ExtensionFunctionType @NonNull Function1<@NonNull MaterialScope, @NonNull LayoutElementBuilders.LayoutElement> iconContent

The icon slot for content displayed in this button. It is recommended to use default styling that is automatically provided by only calling icon with the resource ID.

public static final @NonNull LayoutElementBuilders.LayoutElement textEdgeButton(
    @NonNull MaterialScope receiver,
    @NonNull ModifiersBuilders.Clickable onClick,
    @NonNull LayoutModifier modifier,
    @NonNull ButtonColors colors,
    @ExtensionFunctionType @NonNull Function1<@NonNull MaterialScope, @NonNull LayoutElementBuilders.LayoutElement> labelContent
)

ProtoLayout Material3 component edge button that offers a single slot to take a text or similar long and wide content.

The edge button is intended to be used at the bottom of a round screen. It has a special shape with its bottom almost follows the screen's curvature. It has fixed height, and takes 1 line of text or a single icon. This button represents the most important action on the screen, and it must occupy the whole horizontal space in its position as well as being anchored to the screen bottom.

This component is not intended to be used with an image background.

import androidx.wear.protolayout.material3.button
import androidx.wear.protolayout.material3.materialScope
import androidx.wear.protolayout.material3.text
import androidx.wear.protolayout.material3.textEdgeButton
import androidx.wear.protolayout.modifiers.LayoutModifier
import androidx.wear.protolayout.modifiers.clickable
import androidx.wear.protolayout.modifiers.contentDescription
import androidx.wear.protolayout.types.layoutString

materialScope(context, deviceConfiguration) {
        textEdgeButton(
            onClick = clickable,
            modifier = LayoutModifier.contentDescription("Description of a button")
        ) {
            text("Hello".layoutString)
        }
    }
Parameters
@NonNull ModifiersBuilders.Clickable onClick

Associated Clickable for click events. When the button is clicked it will fire the associated action.

@NonNull LayoutModifier modifier

Modifiers to set to this element. It's highly recommended to set a content description using contentDescription.

@NonNull ButtonColors colors

The colors used for this button. If not set, ButtonDefaults.filledButtonColors will be used as high emphasis button. Other recommended colors are ButtonDefaults.filledTonalButtonColors and ButtonDefaults.filledVariantButtonColors. If using custom colors, it is important to choose a color pair from same role to ensure accessibility with sufficient color contrast.

@ExtensionFunctionType @NonNull Function1<@NonNull MaterialScope, @NonNull LayoutElementBuilders.LayoutElement> labelContent

The label slot for content displayed in this button. It is recommended to use default styling that is automatically provided by only calling text with the content.