ScrollbarLayout

class ScrollbarLayout(val layoutDirection: LayoutDirection, val orientation: Orientation, val viewPortLength: Float, val viewPortCrossAxisLength: Float, val contentLength: Float, val contentOffset: Int, val scrollbarAlpha: Float, val density: Float, val fontScale: Float) : Density

Layout configuration of the scrollable container, providing information on the dimensions, orientation, and content offset.

See also

Constructors

Link copied to clipboard
constructor(layoutDirection: LayoutDirection, orientation: Orientation, viewPortLength: Float, viewPortCrossAxisLength: Float, contentLength: Float, contentOffset: Int, scrollbarAlpha: Float, density: Float, fontScale: Float)

Properties

Link copied to clipboard

The total length of the scrollable content in the primary scroll direction, which may exceed the viewport length if content is scrollable.

Link copied to clipboard

The current offset of the content from the start of the scrollable area, in pixels. Represents how far the content has been scrolled in the primary direction.

Link copied to clipboard
open override val density: Float

The screen density of the device, used for converting between dp and pixels. Implemented from the Density interface.

Link copied to clipboard
open override val fontScale: Float

The scale factor for fonts, used to adjust text size based on user preferences. Implemented from the Density interface.

Link copied to clipboard

The layout direction of the container, specifying whether the content flows left-to-right or right-to-left. See LayoutDirection for available options.

Link copied to clipboard

The orientation of the scrollable content, which can be either horizontal or vertical. See Orientation for available options.

Link copied to clipboard

The opacity of the scrollbar, where 0 is fully transparent and 1 is fully opaque. Used to control the visibility of the scrollbar during interactions.

Link copied to clipboard

The length of the viewport along the cross-axis (e.g., width for vertical scrolling, height for horizontal). Useful for determining the scrollbar's cross-axis positioning.

Link copied to clipboard

The length of the viewport in the primary scroll direction (e.g., height for vertical scrolling, width for horizontal). This represents the visible area of the content.

Functions

Link copied to clipboard
fun calculateBarLength(topPadding: Float = 0.0f, startPadding: Float = 0.0f, bottomPadding: Float = 0.0f, endPadding: Float = 0.0f): Float

Calculates the bar (track) length with the given padding

Link copied to clipboard
fun calculateIndicatorLength(scrollbarLength: Float, minimumIndicatorLength: Float = 24.0f, maximumIndicatorLength: Float = Float.MAX_VALUE): Float

Calculates indicator length required for the given scrollbarLength and contentLength within the given minimumIndicatorLength and maximumIndicatorLength values

Link copied to clipboard
fun calculateIndicatorOffset(scrollbarLength: Float, indicatorLength: Float): Float

Calculates the offset position of the scrollbar indicator (thumb) within the scrollbar track. This offset helps to position the indicator correctly based on the scrollbar's and indicator's lengths.

Link copied to clipboard
open fun Dp.roundToPx(): Int
open fun TextUnit.roundToPx(): Int
Link copied to clipboard
open fun Float.toDp(): Dp
open fun Int.toDp(): Dp
expect open fun TextUnit.toDp(): Dp
Link copied to clipboard
open fun Size.toDpSize(): DpSize
Link copied to clipboard
open fun Dp.toPx(): Float
open fun TextUnit.toPx(): Float
Link copied to clipboard
open fun DpRect.toRect(): Rect
Link copied to clipboard
open fun DpSize.toSize(): Size
Link copied to clipboard
open fun Float.toSp(): TextUnit
open fun Int.toSp(): TextUnit
expect open fun Dp.toSp(): TextUnit