Start native apps faster with the Composables CLI ->
Interface

ButtonGroupState

A state object that allows querying and controlling the state of a ButtonGroup component.

Source set: Android
public sealed interface ButtonGroupState : ScrollableState

A state object that allows querying and controlling the state of a ButtonGroup component.

Properties

currentItemIndex

Source set: Android
public val currentItemIndex: Int

Index of the current child.

The index updates continuously as the user scrolls. To get updates only when the index is "settled", use the current item index when isScrollInProgress is false.

Returns -1 if the ButtonGroup is empty, or if the layout has not been initialized yet.

itemCount

Source set: Android
public val itemCount: Int

The number of items currently within the ButtonGroup.

Functions

scrollToItem

public suspend fun scrollToItem(index: Int)

Jump instantly to the item at index.

If the ButtonGroup has focus, focus will be requested for the child at this index.

animateScrollToItem

public suspend fun animateScrollToItem(
        index: Int,
        animationSpec: FiniteAnimationSpec<Float> =
            ButtonGroupDefaults.AnimateScrollToItemAnimationSpec,
    )

Scroll to the item at index with the given animationSpec.

If the ButtonGroup has focus, focus will be requested for the child at this index.

Last updated: