{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

SegmentedButtonDefaults

@ExperimentalMaterial3Api
public static class SegmentedButtonDefaults


Summary

Public fields

static @NonNull SegmentedButtonDefaults

Public methods

final void

And icon to indicate the segmented button is checked or selected

final void
@Composable
Icon(
    boolean active,
    @Composable @NonNull Function0<Unit> activeContent,
    @Composable Function0<Unit> inactiveContent
)

The default implementation of icons for Segmented Buttons.

final @NonNull BorderStroke
borderStroke(@NonNull Color color, @NonNull Dp width)

Default factory for Segmented Button BorderStroke can be customized through width, and color.

final @NonNull SegmentedButtonColors

Creates a SegmentedButtonColors that represents the different colors used in a SegmentedButton in different states.

final @NonNull SegmentedButtonColors
@Composable
colors(
    @NonNull Color activeContainerColor,
    @NonNull Color activeContentColor,
    @NonNull Color activeBorderColor,
    @NonNull Color inactiveContainerColor,
    @NonNull Color inactiveContentColor,
    @NonNull Color inactiveBorderColor,
    @NonNull Color disabledActiveContainerColor,
    @NonNull Color disabledActiveContentColor,
    @NonNull Color disabledActiveBorderColor,
    @NonNull Color disabledInactiveContainerColor,
    @NonNull Color disabledInactiveContentColor,
    @NonNull Color disabledInactiveBorderColor
)

Creates a SegmentedButtonColors that represents the different colors used in a SegmentedButton in different states.

final @NonNull CornerBasedShape

The shape of the segmented button container, for correct behavior this should or the desired CornerBasedShape should be used with itemShape and passed to each segmented button.

final @NonNull Dp

Default border width used in segmented button

final @NonNull Dp

Icon size to use for icons used in SegmentedButton

final @NonNull Shape
@Composable
itemShape(int index, int count, @NonNull CornerBasedShape baseShape)

A shape constructor that the button in index should have when there are count buttons in the container.

Public fields

INSTANCE

public static @NonNull SegmentedButtonDefaults INSTANCE

Public methods

ActiveIcon

@Composable
public final void ActiveIcon()

And icon to indicate the segmented button is checked or selected

Icon

@Composable
public final void Icon(
    boolean active,
    @Composable @NonNull Function0<Unit> activeContent,
    @Composable Function0<Unit> inactiveContent
)

The default implementation of icons for Segmented Buttons.

Parameters
boolean active

whether the button is activated or not.

@Composable @NonNull Function0<Unit> activeContent

usually a checkmark icon of IconSize dimensions.

@Composable Function0<Unit> inactiveContent

typically an icon of IconSize. It shows only when the button is not checked.

borderStroke

public final @NonNull BorderStroke borderStroke(@NonNull Color color, @NonNull Dp width)

Default factory for Segmented Button BorderStroke can be customized through width, and color. When using a width different than default make sure to also update MultiChoiceSegmentedButtonRow or SingleChoiceSegmentedButtonRow space param.

colors

@Composable
public final @NonNull SegmentedButtonColors colors()

Creates a SegmentedButtonColors that represents the different colors used in a SegmentedButton in different states.

colors

@Composable
public final @NonNull SegmentedButtonColors colors(
    @NonNull Color activeContainerColor,
    @NonNull Color activeContentColor,
    @NonNull Color activeBorderColor,
    @NonNull Color inactiveContainerColor,
    @NonNull Color inactiveContentColor,
    @NonNull Color inactiveBorderColor,
    @NonNull Color disabledActiveContainerColor,
    @NonNull Color disabledActiveContentColor,
    @NonNull Color disabledActiveBorderColor,
    @NonNull Color disabledInactiveContainerColor,
    @NonNull Color disabledInactiveContentColor,
    @NonNull Color disabledInactiveBorderColor
)

Creates a SegmentedButtonColors that represents the different colors used in a SegmentedButton in different states.

Parameters
@NonNull Color activeContainerColor

the color used for the container when enabled and active

@NonNull Color activeContentColor

the color used for the content when enabled and active

@NonNull Color activeBorderColor

the color used for the border when enabled and active

@NonNull Color inactiveContainerColor

the color used for the container when enabled and inactive

@NonNull Color inactiveContentColor

the color used for the content when enabled and inactive

@NonNull Color inactiveBorderColor

the color used for the border when enabled and active

@NonNull Color disabledActiveContainerColor

the color used for the container when disabled and active

@NonNull Color disabledActiveContentColor

the color used for the content when disabled and active

@NonNull Color disabledActiveBorderColor

the color used for the border when disabled and active

@NonNull Color disabledInactiveContainerColor

the color used for the container when disabled and inactive

@NonNull Color disabledInactiveContentColor

the color used for the content when disabled and unchecked

@NonNull Color disabledInactiveBorderColor

the color used for the border when disabled and inactive

getBaseShape

@Composable
public final @NonNull CornerBasedShape getBaseShape()

The shape of the segmented button container, for correct behavior this should or the desired CornerBasedShape should be used with itemShape and passed to each segmented button.

getBorderWidth

public final @NonNull Dp getBorderWidth()

Default border width used in segmented button

getIconSize

public final @NonNull Dp getIconSize()

Icon size to use for icons used in SegmentedButton

itemShape

@Composable
public final @NonNull Shape itemShape(int index, int count, @NonNull CornerBasedShape baseShape)

A shape constructor that the button in index should have when there are count buttons in the container.

Parameters
int index

the index for this button in the row

int count

the count of buttons in this row

@NonNull CornerBasedShape baseShape

the CornerBasedShape the base shape that should be used in buttons that are not in the start or the end.