Expand description
The curved scroll indicator a round watch puts at 3 o’clock.
Every round-screen app needs this and none of it is guessable: the track is described by a height in dp rather than an angle, the thumb is a separate segment with a gap at each end rather than paint over a continuous rail, and a segment shorter than its own stroke turns into a shrinking, fading dot instead of a stubby arc.
The numbers and the arithmetic here were read out of
androidx.wear.compose.material3 1.6.2 with javap -c and then checked
against where the shipping Compose build actually puts pixels on 454x454 and
384x384 displays. The sources are named per item so the next person can
re-derive them rather than trust this comment.
This module is deliberately pure geometry. It returns the segments to draw and takes no view of how they are drawn, so it costs nothing to a platform that never shows it and can be tested without a GPU.
Structs§
- Indicator
Arc - Where the track sits on a display of the given radius.
- Indicator
Geometry - Where the thumb sits inside the track and how long it is, both as fractions of the whole track.
- Indicator
Item - One row of a
ScalingLazyColumn, asScalingLazyListItemInforeports it. - Scaling
List - A scaling list as
ScalingLazyColumnStateAdaptersees it. Device pixels. - Thumb
Length - The thumb’s length, and the fact that Wear only measures it once.
Enums§
- Indicator
Part - Which part of the indicator a segment belongs to, so a caller can colour the thumb and the track differently without re-deriving the order.
- Indicator
Segment - One piece of the indicator, ready to draw.
Constants§
- INDICATOR_
EDGE_ PADDING_ DP PaddingDefaults.edgePadding— how far the track’s outer edge stays off the display edge.- INDICATOR_
GAP_ DP ScrollIndicatorDefaults.gapHeight— the blank left between the thumb and each end of the track.- INDICATOR_
HEIGHT_ DP ScrollIndicatorDefaults.indicatorHeight— how far the track reaches up and down from 3 o’clock, as a straight-line height rather than an arc length.- INDICATOR_
LARGE_ SCREEN_ DP - Wear’s own breakpoint: a display at least this wide gets the wider stroke.
- INDICATOR_
MAX_ THUMB - INDICATOR_
MIN_ THUMB ScrollIndicatorDefaults.minSizeFraction/maxSizeFraction— the thumb’s share of the track is clamped to this range however long the list is.- INDICATOR_
NARROW_ WIDTH_ DP - INDICATOR_
WIDTH_ DP ScrollIndicatorDefaults.indicatorWidth, whose two values are chosen by screen size.
Functions§
- decimal_
first_ item_ index - Where the first visible row sits, as a fractional item index.
- decimal_
last_ item_ index - Where the last visible row sits, as a fractional item index.
- indicator_
arc - Where the track’s centreline sits and how far it sweeps.
- indicator_
geometry - Works out the thumb for a list, or
Nonewhen everything fits on screen and Wear shows nothing at all. - indicator_
segments - The whole indicator as a list of drawable pieces: track, thumb, track.
- indicator_
width_ dp - The stroke width Wear would use on a display this wide.
- position_
fraction - How far down the track the thumb’s leading edge sits, before the thumb’s own
length is taken out of the travel.
0.0at the top,1.0at the bottom. - scaling_
list_ geometry - The thumb for a
ScalingLazyColumn, in the item-index space Wear uses. - scaling_
list_ items - The rows of a laid-out scaling list that are on screen, as the adapter reads them, for a list scaled by Wear’s own ramp.
- scaling_
list_ items_ with scaling_list_itemsfor a list whose ramp is not the default one.