androidx.wear.compose.material3.onehandedgesture
Classes
GestureAction |
Defines the distinct actions of one-handed gestures supported by the system. |
GestureIndicatorSize |
Represents the size of the gesture indicator icon. |
GesturePriority |
Defines the fixed precedence levels for one-handed gesture interception. |
OneHandedGestureConfiguration |
Represents the persistent specification for a one-handed gesture. |
OneHandedGestureIndicatorState |
A state object used to coordinate visual feedback between a |
Objects
Composables
OneHandedGestureHorizontalPageIndicator |
A horizontal page indicator that can temporarily display a gesture indicator to demonstrate how to navigate between pages using one-handed gestures. |
OneHandedGestureIndicator |
A wrapper that replaces the |
OneHandedGestureScrollIndicator |
A scroll indicator that transitions to indicate that a scroll gesture is available to the user. |
OneHandedGestureVerticalPageIndicator |
A vertical page indicator that can temporarily display a gesture indicator to demonstrate how to navigate between pages using one-handed gestures. |
rememberOneHandedGestureConfiguration |
A |
Modifiers
oneHandedGesture |
Registers a gesture handler. |
Top-level properties summary
ProvidableCompositionLocal<Boolean> |
CompositionLocal that controls whether one-handed gestures are enabled within the provided composition tree. |
Top-level properties
LocalOneHandedGestureEnabled
val LocalOneHandedGestureEnabled: ProvidableCompositionLocal<Boolean>
CompositionLocal that controls whether one-handed gestures are enabled within the provided composition tree.
When set to true (the default), any Modifier.oneHandedGesture applied within this composition scope will actively track and process one-handed gestures. When provided with false, those modifiers will gracefully ignore relevant touch events without being removed from the composition tree. Example usage:
CompositionLocalProvider(LocalOneHandedGestureEnabled provides false) {
// Any oneHandedGesture modifiers inside this component will be disabled
MyEncapsulatedScreenContent()
}
Sample demonstrating how to disable gesture:
import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.height import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import androidx.wear.compose.material3.Button import androidx.wear.compose.material3.SwitchButton import androidx.wear.compose.material3.Text import androidx.wear.compose.material3.onehandedgesture.GestureAction import androidx.wear.compose.material3.onehandedgesture.LocalOneHandedGestureEnabled import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureIndicator import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureIndicatorState import androidx.wear.compose.material3.onehandedgesture.oneHandedGesture import androidx.wear.compose.material3.onehandedgesture.rememberOneHandedGestureConfiguration var counter by remember { mutableIntStateOf(0) } var enabled by remember { mutableStateOf(true) } val interactionSource = remember { MutableInteractionSource() } Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { Column(horizontalAlignment = Alignment.CenterHorizontally) { SwitchButton(checked = enabled, onCheckedChange = { enabled = it }) { Text("Gestures enabled") } Spacer(modifier = Modifier.height(6.dp)) CompositionLocalProvider(LocalOneHandedGestureEnabled provides enabled) { val gestureConfig = rememberOneHandedGestureConfiguration(action = GestureAction.Primary) val indicatorState = remember { OneHandedGestureIndicatorState() } Button( onClick = {}, interactionSource = interactionSource, modifier = Modifier.oneHandedGesture( gestureConfiguration = gestureConfig, interactionSource = interactionSource, onGestureLabel = "increase the counter", onGestureAvailable = { indicatorState.isIndicatorActive = true }, onGesture = { counter++ }, ), ) { OneHandedGestureIndicator(gestureConfig, indicatorState) { Text("Gestured $counter times") } } } } }