androidx.compose.foundation
Interfaces
AndroidExternalSurfaceScope |
|
android
|
BasicTooltipState |
The state that is associated with an instance of a tooltip. |
Cmn
|
Indication |
Indication represents visual effects that occur when certain interactions happens. |
Cmn
|
IndicationInstance |
This interface is deprecated. IndicationInstance has been deprecated along with the rememberUpdatedInstance that returns it. |
Cmn
|
IndicationNodeFactory |
IndicationNodeFactory is an Indication that creates |
Cmn
|
MarqueeSpacing |
Defines a |
Cmn
|
OverscrollEffect |
An OverscrollEffect represents a visual effect that displays when the edges of a scrolling container have been reached with a scroll or fling. |
Cmn
|
OverscrollFactory |
A factory for creating |
Cmn
|
ScrollIndicatorState |
Represents the state required to draw a scroll indicator (e.g., a scrollbar), which is typically provided by a scrollable component. |
Cmn
|
SurfaceCoroutineScope |
|
android
|
SurfaceScope |
|
android
|
Classes
AndroidExternalSurfaceZOrder |
Defines the z-order of an |
android
|
BorderStroke |
Class to specify the stroke to draw border with. |
Cmn
|
MarqueeAnimationMode |
Specifies when the |
Cmn
|
MutatorMutex |
Mutual exclusion for UI state mutation over time. |
Cmn
|
OverscrollConfiguration |
This class is deprecated. Providing `OverscrollConfiguration` through `LocalOverscrollConfiguration` to disable / configure overscroll has been replaced with `LocalOverscrollFactory` and `rememberPlatformOverscrollFactory`. |
android
|
ScrollState |
State of the scroll. |
Cmn
|
Objects
BasicTooltipDefaults |
BasicTooltip defaults that contain default values for tooltips created. |
Cmn
|
ComposeFoundationFlags |
This is a collection of flags which are used to guard against regressions in some of the "riskier" refactors or new feature support that is added to this module. |
Cmn
|
MarqueeDefaults |
Namespace for constants representing the default values for various |
Cmn
|
Annotations
Enums
MutatePriority |
Priorities for performing mutation on state. |
Cmn
|
Composables
AndroidEmbeddedExternalSurface |
Provides a dedicated drawing |
android
|
AndroidExternalSurface |
Provides a dedicated drawing |
android
|
BasicTooltipBox |
BasicTooltipBox that wraps a composable with a tooltip. |
Cmn
|
Canvas |
Component that allow you to specify an area on the screen and perform canvas drawing on this area. |
Cmn
|
Image |
A composable that lays out and draws a given |
Cmn
|
isSystemInDarkTheme |
Returns whether the operating system is in dark theme. |
Cmn
|
rememberBasicTooltipState |
Create and remember the default |
Cmn
|
rememberOverscrollEffect |
Returns a remembered |
Cmn
|
rememberPlatformOverscrollFactory |
Creates and remembers an instance of the platform |
android
|
rememberScrollState |
Create and |
Cmn
|
Modifiers
background |
Cmn
|
|
basicMarquee |
Applies an animated marquee effect to the modified content if it's too wide to fit in the available space. |
Cmn
|
border |
Modify element to add border with appearance specified with a |
Cmn
|
clickable |
Configure component to receive clicks via input or accessibility "click" event. |
Cmn
|
clipScrollableContainer |
Clips bounds of scrollable container on main axis while leaving space for background effects (like shadows) on cross axis. |
Cmn
|
combinedClickable |
Configure component to receive clicks, double clicks and long clicks via input or accessibility "click" event. |
Cmn
|
excludeFromSystemGesture |
Excludes the layout rectangle from the system gesture. |
android
|
focusGroup |
Creates a focus group or marks this component as a focus group. |
Cmn
|
focusable |
Configure component to be focusable via focus system or accessibility "focus" event. |
Cmn
|
horizontalScroll |
Modify element to allow to scroll horizontally when width of the content is bigger than max constraints allow. |
Cmn
|
hoverable |
Configure component to be hoverable via pointer enter/exit events. |
Cmn
|
indication |
Draws visual effects for this component when interactions occur. |
Cmn
|
magnifier |
Shows a |
android
|
onFocusedBoundsChanged |
Calls |
Cmn
|
overscroll |
Renders overscroll from the provided |
Cmn
|
preferKeepClear |
Mark the layout rectangle as preferring to stay clear of floating windows. |
android
|
progressSemantics |
Contains the |
Cmn
|
scrollableArea |
Configure a component to act as a scrollable area. |
Cmn
|
systemGestureExclusion |
Excludes the layout rectangle from the system gesture. |
android
|
verticalScroll |
Modify element to allow to scroll vertically when height of the content is bigger than max constraints allow. |
Cmn
|
Top-level functions summary
BasicTooltipState |
@ExperimentalFoundationApiConstructor extension function for |
Cmn
|
BorderStroke |
BorderStroke(width: Dp, color: Color)Create |
Cmn
|
MarqueeSpacing |
MarqueeSpacing(spacing: Dp)A |
Cmn
|
Unit |
checkScrollableContainerConstraints( |
Cmn
|
Extension functions summary
OverscrollEffect |
Returns a wrapped version of |
Cmn
|
OverscrollEffect |
Returns a wrapped version of |
Cmn
|
Top-level properties summary
ProvidableCompositionLocal<Indication> |
CompositionLocal that provides an |
Cmn
|
ProvidableCompositionLocal<OverscrollConfiguration?> |
This property is deprecated. Providing `OverscrollConfiguration` through `LocalOverscrollConfiguration` to disable / configure overscroll has been replaced with `LocalOverscrollFactory` and `rememberPlatformOverscrollFactory`. |
android
|
ProvidableCompositionLocal<OverscrollFactory?> |
CompositionLocal that provides an |
Cmn
|
Top-level functions
BasicTooltipState
@ExperimentalFoundationApi
fun BasicTooltipState(
initialIsVisible: Boolean = false,
isPersistent: Boolean = true,
mutatorMutex: MutatorMutex = BasicTooltipDefaults.GlobalMutatorMutex
): BasicTooltipState
Constructor extension function for BasicTooltipState
| Parameters | |
|---|---|
initialIsVisible: Boolean = false |
the initial value for the tooltip's visibility when drawn. |
isPersistent: Boolean = true |
|
mutatorMutex: MutatorMutex = BasicTooltipDefaults.GlobalMutatorMutex |
|
BorderStroke
fun BorderStroke(width: Dp, color: Color): BorderStroke
Create BorderStroke class with width and Color
| Parameters | |
|---|---|
width: Dp |
width of the border in |
color: Color |
color to paint the border with |
checkScrollableContainerConstraints
fun checkScrollableContainerConstraints(
constraints: Constraints,
orientation: Orientation
): Unit
| Parameters | |
|---|---|
constraints: Constraints |
|
orientation: Orientation |
orientation of the scrolling |
| Throws | |
|---|---|
IllegalStateException |
if the container was measured with the infinity constraints in the direction of scrolling. This usually means nesting scrollable in the same direction containers which is a performance issue and is discouraged. |
Extension functions
OverscrollEffect.withoutEventHandling
fun OverscrollEffect.withoutEventHandling(): OverscrollEffect
Returns a wrapped version of this that will not handle any incoming events. This means that calls to OverscrollEffect.applyToScroll / OverscrollEffect.applyToFling will directly execute the provided performScroll / performFling lambdas, without the OverscrollEffect ever seeing the incoming values. OverscrollEffect.node will still be attached, so that overscroll can render.
This can be useful if you want to render an OverscrollEffect in a different component that normally provides events to overscroll, such as a androidx.compose.foundation.lazy.LazyColumn. Use this along with withoutVisualEffect to create two wrapped instances: one that does not handle events, and one that does not draw, so you can ensure that the overscroll effect is only rendered once, and only receives events from one source.
| See also | |
|---|---|
withoutVisualEffect |
OverscrollEffect.withoutVisualEffect
fun OverscrollEffect.withoutVisualEffect(): OverscrollEffect
Returns a wrapped version of this with an empty OverscrollEffect.node. This prevents the overscroll effect from applying any visual effect, but it will still handle events.
This can be used along with withoutEventHandling in cases where you wish to change where overscroll is rendered for a given component. Pass this wrapped instance that doesn't render to the component that handles events (such as androidx.compose.foundation.lazy.LazyColumn) to prevent it from drawing the overscroll effect. Then to separately render the original overscroll effect, you can directly pass it to Modifier.overscroll (since that modifier only renders, and does not handle events). If instead you want to draw the overscroll in another component that handles events, such as a different lazy list, you need to first wrap the original overscroll effect with withoutEventHandling to prevent it from also dispatching events.
import androidx.compose.foundation.OverscrollEffect import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.overscroll import androidx.compose.foundation.rememberOverscrollEffect import androidx.compose.foundation.withoutVisualEffect import androidx.compose.material.Text import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.drawBehind import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.unit.dp val items = remember { (1..100).toList() } val state = rememberLazyListState() val overscroll = rememberOverscrollEffect() // Create a wrapped version of the above overscroll effect that does not apply a visual effect. // This will be used inside LazyColumn to provide events to overscroll, without letting // LazyColumn render the overscroll effect internally. val overscrollWithoutVisualEffect = overscroll?.withoutVisualEffect() LazyColumn( content = { items(items) { Text("Item $it") } }, state = state, modifier = Modifier.size(300.dp) .clip(RectangleShape) // Manually render the overscroll on top of the lazy list _and_ the 'decorations' we // are // manually drawing, to make sure they will also be included in the overscroll // effect. .overscroll(overscroll) .drawBehind { state.layoutInfo.visibleItemsInfo.drop(1).forEach { info -> val verticalOffset = info.offset.toFloat() drawLine( color = Color.Red, start = Offset(0f, verticalOffset), end = Offset(size.width, verticalOffset), ) } }, // Pass the overscroll effect that does not apply a visual effect inside the LazyList to // receive overscroll events overscrollEffect = overscrollWithoutVisualEffect, )
| See also | |
|---|---|
withoutEventHandling |
Top-level properties
LocalIndication
val LocalIndication: ProvidableCompositionLocal<Indication>
CompositionLocal that provides an Indication through the hierarchy. This Indication will be used by default to draw visual effects for interactions such as press and drag in components such as clickable.
By default this will provide a debug indication, this should always be replaced.
LocalOverscrollConfiguration
@ExperimentalFoundationApi
val LocalOverscrollConfiguration: ProvidableCompositionLocal<OverscrollConfiguration?>
Composition local to provide configuration for scrolling containers down the hierarchy. null means there will be no overscroll at all.
LocalOverscrollFactory
val LocalOverscrollFactory: ProvidableCompositionLocal<OverscrollFactory?>
CompositionLocal that provides an OverscrollFactory through the hierarchy. This will be used by default by scrolling components, so you can provide an OverscrollFactory here to override the overscroll used by components within a hierarchy.
See rememberOverscrollEffect to remember an OverscrollEffect from the current provided value.