State of Compose 2023 results are in! Click here to learn more

← Back to Wear Material

PositionIndicator

Component
in
Wear Material
. Since 1.0.0

Overview

Code Examples

Creates an PositionIndicator based on the values in a ScrollState object. e.g. a Column implementing Modifier.verticalScroll provides a ScrollState.

For more information, see the Scroll indicators(https://developer.android.com/training/wearables/components/scroll) guide.

@param scrollState The scrollState to use as the basis for the PositionIndicatorState. @param modifier The modifier to be applied to the component @param reverseDirection Reverses direction of PositionIndicator if true @param showFadeInAnimation turns on the "Fade-in" animation of PositionIndicator. If true, the Fade-in animation is triggered when the PositionIndicator becomes visible - either when state.visibility changes to Show, or state.visibility is AutoHide and state.positionFraction/state.sizeFraction are changed. @param showFadeOutAnimation turns on the "Fade-out" animation of PositionIndicator. The Fade-out animation is used for hiding the PositionIndicator and making it invisible. If true, the Fade-out animation is triggered after a delay if no changes in state.positionFraction or state.sizeFraction were detected, hiding the PositionIndicator with animation. @param showPositionAnimation turns on the "Position" animation of PositionIndicator. The Position animation is used for animating changes between state.positionFraction and state.sizeFraction of PositionIndicatorState. If true, the Position animation will be triggered on any change of state.positionFraction or state.sizeFraction.

Overloads

PositionIndicator

@Composable
public fun PositionIndicator(
    scrollState: ScrollState,
    modifier: Modifier = Modifier,
    reverseDirection: Boolean = false,
    showFadeInAnimation: Boolean = true,
    showFadeOutAnimation: Boolean = true,
    showPositionAnimation: Boolean = true
)

Parameters

NameDescription
scrollStateThe scrollState to use as the basis for the PositionIndicatorState.
modifierThe modifier to be applied to the component
reverseDirectionReverses direction of PositionIndicator if true
showFadeInAnimationturns on the "Fade-in" animation of PositionIndicator. If true, the Fade-in animation is triggered when the PositionIndicator becomes visible - either when state.visibility changes to Show, or state.visibility is AutoHide and state.positionFraction/state.sizeFraction are changed.
showFadeOutAnimationturns on the "Fade-out" animation of PositionIndicator. The Fade-out animation is used for hiding the PositionIndicator and making it invisible. If true, the Fade-out animation is triggered after a delay if no changes in state.positionFraction or state.sizeFraction were detected, hiding the PositionIndicator with animation.
showPositionAnimationturns on the "Position" animation of PositionIndicator. The Position animation is used for animating changes between state.positionFraction and state.sizeFraction of PositionIndicatorState. If true, the Position animation will be triggered on any change of state.positionFraction or state.sizeFraction

PositionIndicator

@Deprecated(
    "This overload is provided for backwards compatibility with " +
        "Compose for Wear OS 1.2." +
        "A newer overload is available with additional showFadeInAnimation, " +
        "showFadeOutAnimation and showPositionAnimation parameters.",
    level = DeprecationLevel.HIDDEN
)
@Composable
public fun PositionIndicator(
    scrollState: ScrollState,
    modifier: Modifier = Modifier,
    reverseDirection: Boolean = false
)

Parameters

NameDescription
scrollStateThe scrollState to use as the basis for the PositionIndicatorState.
modifierThe modifier to be applied to the component
reverseDirectionReverses direction of PositionIndicator if tru

PositionIndicator

@Composable
public fun PositionIndicator(
    scalingLazyListState: ScalingLazyListState,
    modifier: Modifier = Modifier,
    reverseDirection: Boolean = false,
    showFadeInAnimation: Boolean = true,
    showFadeOutAnimation: Boolean = true,
    showPositionAnimation: Boolean = true
)

Parameters

NameDescription
scalingLazyListStatethe ScalingLazyListState to use as the basis for the PositionIndicatorState.
modifierThe modifier to be applied to the component
reverseDirectionReverses direction of PositionIndicator if true
showFadeInAnimationturns on the "Fade-in" animation of PositionIndicator. If true, the Fade-in animation is triggered when the PositionIndicator becomes visible - either when state.visibility changes to Show, or state.visibility is AutoHide and state.positionFraction/state.sizeFraction are changed.
showFadeOutAnimationturns on the "Fade-out" animation of PositionIndicator. The Fade-out animation is used for hiding the PositionIndicator and making it invisible. If true, the Fade-out animation is triggered after a delay if no changes in state.positionFraction or state.sizeFraction were detected, hiding the PositionIndicator with animation.
showPositionAnimationturns on the "Position" animation of PositionIndicator. The Position animation is used for animating changes between state.positionFraction and state.sizeFraction of PositionIndicatorState. If true, the Position animation will be triggered on any change of state.positionFraction or state.sizeFraction

PositionIndicator

@Deprecated(
    "This overload is provided for backwards compatibility with " +
        "Compose for Wear OS 1.2." +
        "A newer overload is available with additional showFadeInAnimation, " +
        "showFadeOutAnimation and showPositionAnimation parameters.",
    level = DeprecationLevel.HIDDEN
)
@Composable
public fun PositionIndicator(
    scalingLazyListState: ScalingLazyListState,
    modifier: Modifier = Modifier,
    reverseDirection: Boolean = false
)

Parameters

NameDescription
scalingLazyListStatethe ScalingLazyListState to use as the basis for the PositionIndicatorState.
modifierThe modifier to be applied to the component
reverseDirectionReverses direction of PositionIndicator if tru

PositionIndicator

@Suppress("DEPRECATION")
@Deprecated(
    "This overload is provided for backwards compatibility with Compose for Wear OS 1.1." +
        "A newer overload is available which uses ScalingLazyListState from " +
        "androidx.wear.compose.foundation.lazy package", level = DeprecationLevel.WARNING
)
@Composable
public fun PositionIndicator(
    scalingLazyListState: androidx.wear.compose.material.ScalingLazyListState,
    modifier: Modifier = Modifier,
    reverseDirection: Boolean = false
)

Parameters

NameDescription
scalingLazyListStatethe ScalingLazyListState to use as the basis for the PositionIndicatorState.
modifierThe modifier to be applied to the component
reverseDirectionReverses direction of PositionIndicator if tru

PositionIndicator

@Composable
public fun PositionIndicator(
    lazyListState: LazyListState,
    modifier: Modifier = Modifier,
    reverseDirection: Boolean = false,
    showFadeInAnimation: Boolean = true,
    showFadeOutAnimation: Boolean = true,
    showPositionAnimation: Boolean = true
)

Parameters

NameDescription
lazyListStatethe LazyListState to use as the basis for the PositionIndicatorState.
modifierThe modifier to be applied to the component
reverseDirectionReverses direction of PositionIndicator if true
showFadeInAnimationturns on the "Fade-in" animation of PositionIndicator. If true, the Fade-in animation is triggered when the PositionIndicator becomes visible - either when state.visibility changes to Show, or state.visibility is AutoHide and state.positionFraction/state.sizeFraction are changed.
showFadeOutAnimationturns on the "Fade-out" animation of PositionIndicator. The Fade-out animation is used for hiding the PositionIndicator and making it invisible. If true, the Fade-out animation is triggered after a delay if no changes in state.positionFraction or state.sizeFraction were detected, hiding the PositionIndicator with animation.
showPositionAnimationturns on the "Position" animation of PositionIndicator. The Position animation is used for animating changes between state.positionFraction and state.sizeFraction of PositionIndicatorState. If true, the Position animation will be triggered on any change of state.positionFraction or state.sizeFraction

PositionIndicator

@Deprecated(
    "This overload is provided for backwards compatibility with " +
        "Compose for Wear OS 1.2." +
        "A newer overload is available with additional showFadeInAnimation, " +
        "showFadeOutAnimation and showPositionAnimation parameters.",
    level = DeprecationLevel.HIDDEN
)
@Composable
public fun PositionIndicator(
    lazyListState: LazyListState,
    modifier: Modifier = Modifier,
    reverseDirection: Boolean = false
)

Parameters

NameDescription
lazyListStatethe LazyListState to use as the basis for the PositionIndicatorState.
modifierThe modifier to be applied to the component
reverseDirectionReverses direction of PositionIndicator if tru

PositionIndicator

@Composable
public fun PositionIndicator(
    @Suppress("PrimitiveInLambda")
    value: () -> Float,
    modifier: Modifier = Modifier,
    range: ClosedFloatingPointRange<Float> = 0f..1f,
    color: Color = MaterialTheme.colors.onBackground,
    reverseDirection: Boolean = false,
    position: PositionIndicatorAlignment = PositionIndicatorAlignment.OppositeRsb,
    showFadeInAnimation: Boolean = true,
    showFadeOutAnimation: Boolean = true,
    showPositionAnimation: Boolean = true
)

Parameters

NameDescription
valueValue of the indicator in the range where 1 represents the maximum value. E.g. If displaying a volume value from 0..11 then the value will be volume/11.
rangerange of values that value can take
modifierModifier to be applied to the component
colorColor to draw the indicator on.
reverseDirectionReverses direction of PositionIndicator if true
positionindicates where to put the PositionIndicator in the screen, default is PositionIndicatorPosition#OppositeRsb
showFadeInAnimationturns on the "Fade-in" animation of PositionIndicator. If true, the Fade-in animation is triggered when the PositionIndicator becomes visible - either when state.visibility changes to Show, or state.visibility is AutoHide and state.positionFraction/state.sizeFraction are changed.
showFadeOutAnimationturns on the "Fade-out" animation of PositionIndicator. The Fade-out animation is used for hiding the PositionIndicator and making it invisible. If true, the Fade-out animation is triggered after a delay if no changes in state.positionFraction or state.sizeFraction were detected, hiding the PositionIndicator with animation.
showPositionAnimationturns on the "Position" animation of PositionIndicator. The Position animation is used for animating changes between state.positionFraction and state.sizeFraction of PositionIndicatorState. If true, the Position animation will be triggered on any change of state.positionFraction or state.sizeFraction

PositionIndicator

@Deprecated(
    "This overload is provided for backwards compatibility with " +
        "Compose for Wear OS 1.2." +
        "A newer overload is available with additional showFadeInAnimation, " +
        "showFadeOutAnimation and showPositionAnimation parameters.",
    level = DeprecationLevel.HIDDEN
)
@Composable
public fun PositionIndicator(
    @Suppress("PrimitiveInLambda")
    value: () -> Float,
    modifier: Modifier = Modifier,
    range: ClosedFloatingPointRange<Float> = 0f..1f,
    color: Color = MaterialTheme.colors.onBackground,
    reverseDirection: Boolean = false,
    position: PositionIndicatorAlignment = PositionIndicatorAlignment.OppositeRsb
)

Parameters

NameDescription
valueValue of the indicator in the range where 1 represents the maximum value. E.g. If displaying a volume value from 0..11 then the value will be volume/11.
rangerange of values that value can take
modifierModifier to be applied to the component
colorColor to draw the indicator on.
reverseDirectionReverses direction of PositionIndicator if true
positionindicates where to put the PositionIndicator in the screen, default is PositionIndicatorPosition#OppositeRsb

PositionIndicator

@Composable
public fun PositionIndicator(
    state: PositionIndicatorState,
    indicatorHeight: Dp,
    indicatorWidth: Dp,
    paddingHorizontal: Dp,
    modifier: Modifier = Modifier,
    background: Color = MaterialTheme.colors.onBackground.copy(alpha = 0.3f),
    color: Color = MaterialTheme.colors.onBackground,
    reverseDirection: Boolean = false,
    position: PositionIndicatorAlignment = PositionIndicatorAlignment.End,
    showFadeInAnimation: Boolean = true,
    showFadeOutAnimation: Boolean = true,
    showPositionAnimation: Boolean = true
)

Parameters

NameDescription
statethe PositionIndicatorState of the state we are displaying.
indicatorHeightthe height of the position indicator in Dp.
indicatorWidththe width of the position indicator in Dp.
paddingHorizontalthe padding to apply between the indicator and the border of the screen.
modifierThe modifier to be applied to the component.
backgroundthe color to draw the non-active part of the position indicator.
colorthe color to draw the active part of the indicator in.
reverseDirectionReverses direction of PositionIndicator if true.
positionindicates where to put the PositionIndicator on the screen, default is PositionIndicatorPosition#End
showFadeInAnimationturns on the "Fade-in" animation of PositionIndicator. If true, the Fade-in animation is triggered when the PositionIndicator becomes visible - either when state.visibility changes to Show, or state.visibility is AutoHide and state.positionFraction/state.sizeFraction are changed.
showFadeOutAnimationturns on the "Fade-out" animation of PositionIndicator. The Fade-out animation is used for hiding the PositionIndicator and making it invisible. If true, the Fade-out animation is triggered after a delay if no changes in state.positionFraction or state.sizeFraction were detected, hiding the PositionIndicator with animation.
showPositionAnimationturns on the "Position" animation of PositionIndicator. The Position animation is used for animating changes between state.positionFraction and state.sizeFraction of PositionIndicatorState. If true, the Position animation will be triggered on any change of state.positionFraction or state.sizeFraction

PositionIndicator

@Deprecated(
    "This overload is provided for backwards compatibility with " +
        "Compose for Wear OS 1.2." +
        "A newer overload is available with additional showFadeInAnimation, " +
        "showFadeOutAnimation and showPositionAnimation parameters.",
    level = DeprecationLevel.HIDDEN
)
@Composable
public fun PositionIndicator(
    state: PositionIndicatorState,
    indicatorHeight: Dp,
    indicatorWidth: Dp,
    paddingHorizontal: Dp,
    modifier: Modifier = Modifier,
    background: Color = MaterialTheme.colors.onBackground.copy(alpha = 0.3f),
    color: Color = MaterialTheme.colors.onBackground,
    reverseDirection: Boolean = false,
    position: PositionIndicatorAlignment = PositionIndicatorAlignment.End
)

Parameters

NameDescription
statethe PositionIndicatorState of the state we are displaying.
indicatorHeightthe height of the position indicator in Dp.
indicatorWidththe width of the position indicator in Dp.
paddingHorizontalthe padding to apply between the indicator and the border of the screen.
modifierThe modifier to be applied to the component.
backgroundthe color to draw the non-active part of the position indicator.
colorthe color to draw the active part of the indicator in.
reverseDirectionReverses direction of PositionIndicator if true.
positionindicates where to put the PositionIndicator on the screen, default is PositionIndicatorPosition#End