verticalScroll
Functions summary
Modifier |
Modifier.verticalScroll(Modify element to allow to scroll vertically when height of the content is bigger than max constraints allow. |
Cmn
|
Modifier |
Modifier.verticalScroll(Modify element to allow to scroll vertically when height of the content is bigger than max constraints allow. |
Cmn
|
Functions
Modifier.verticalScroll
fun Modifier.verticalScroll(
state: ScrollState,
enabled: Boolean = true,
flingBehavior: FlingBehavior? = null,
reverseScrolling: Boolean = false
): Modifier
Modify element to allow to scroll vertically when height of the content is bigger than max constraints allow.
import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.requiredHeight import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.TileMode import androidx.compose.ui.unit.dp val scrollState = rememberScrollState() val gradient = Brush.verticalGradient( listOf(Color.Red, Color.Blue, Color.Green), 0.0f, 10000.0f, TileMode.Repeated, ) Box( Modifier.verticalScroll(scrollState) .fillMaxWidth() .requiredHeight(10000.dp) .background(brush = gradient) )
In order to use this modifier, you need to create and own ScrollState
See the other overload in order to provide a custom OverscrollEffect
| Parameters | |
|---|---|
state: ScrollState |
state of the scroll |
enabled: Boolean = true |
whether or not scrolling via touch input is enabled |
flingBehavior: FlingBehavior? = null |
logic describing fling behavior when drag has finished with velocity. If |
reverseScrolling: Boolean = false |
reverse the direction of scrolling, when |
| See also | |
|---|---|
rememberScrollState |
Modifier.verticalScroll
fun Modifier.verticalScroll(
state: ScrollState,
overscrollEffect: OverscrollEffect?,
enabled: Boolean = true,
flingBehavior: FlingBehavior? = null,
reverseScrolling: Boolean = false
): Modifier
Modify element to allow to scroll vertically when height of the content is bigger than max constraints allow.
import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.requiredHeight import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.TileMode import androidx.compose.ui.unit.dp val scrollState = rememberScrollState() val gradient = Brush.verticalGradient( listOf(Color.Red, Color.Blue, Color.Green), 0.0f, 10000.0f, TileMode.Repeated, ) Box( Modifier.verticalScroll(scrollState) .fillMaxWidth() .requiredHeight(10000.dp) .background(brush = gradient) )
In order to use this modifier, you need to create and own ScrollState
| Parameters | |
|---|---|
state: ScrollState |
state of the scroll |
overscrollEffect: OverscrollEffect? |
the |
enabled: Boolean = true |
whether or not scrolling via touch input is enabled |
flingBehavior: FlingBehavior? = null |
logic describing fling behavior when drag has finished with velocity. If |
reverseScrolling: Boolean = false |
reverse the direction of scrolling, when |
| See also | |
|---|---|
rememberScrollState |