Android 12 Developer Preview is here! Try it out, and give us your feedback!

SwipeableDefaults

object SwipeableDefaults
kotlin.Any
   ↳ androidx.compose.material.SwipeableDefaults

Contains useful defaults for swipeable and SwipeableState.

Summary

Constants
const Float

A standard resistance factor which indicates that the user has run out of things to see.

const Float

A stiff resistance factor which indicates that swiping isn't available right now.

Public methods
ResistanceConfig?
resistanceConfig(anchors: Set<Float>, factorAtMin: Float = StandardResistanceFactor, factorAtMax: Float = StandardResistanceFactor)

The default resistance config used by swipeable.

Properties
SpringSpec<Float>

The default animation used by SwipeableState.

Dp

The default velocity threshold (1.

Constants

StandardResistanceFactor

const val StandardResistanceFactor: Float

A standard resistance factor which indicates that the user has run out of things to see.

Value: 10f

StiffResistanceFactor

const val StiffResistanceFactor: Float

A stiff resistance factor which indicates that swiping isn't available right now.

Value: 20f

Public methods

resistanceConfig

fun resistanceConfig(
    anchors: Set<Float>,
    factorAtMin: Float = StandardResistanceFactor,
    factorAtMax: Float = StandardResistanceFactor
): ResistanceConfig?

The default resistance config used by swipeable.

This returns null if there is one anchor. If there are at least two anchors, it returns a ResistanceConfig with the resistance basis equal to the distance between the two bounds.

Properties

AnimationSpec

val AnimationSpec: SpringSpec<Float>

The default animation used by SwipeableState.

VelocityThreshold

val VelocityThreshold: Dp

The default velocity threshold (1.8 dp per millisecond) used by swipeable.