curveToEdge

Functions summary

Modifier
@RequiresApi(value = 33)
Modifier.curveToEdge(
    maxSweepAngle: Float,
    angularDirection: AngularDirection,
    anchor: Float,
    anchorType: AngularAnchorType
)

A Modifier that curves a component to the border of the parent container around the center, always treating the container as a circle.

Functions

Modifier.curveToEdge

@RequiresApi(value = 33)
fun Modifier.curveToEdge(
    maxSweepAngle: Float = CurvedTextDefaults.ScrollableContentMaxSweepAngle,
    angularDirection: AngularDirection = AngularDirection.Clockwise,
    anchor: Float = 270.0f,
    anchorType: AngularAnchorType = AngularAnchorType.Center
): Modifier

A Modifier that curves a component to the border of the parent container around the center, always treating the container as a circle. Useful for circular screens. It draws outside the bounds of the container, then a shader is applied that calculates and draws the curved content.

If the container is a rectangle, it will be treated as a circle with radius of the height divided by 2.

Content towards the center of the container will be smaller due to the method of calculating the curve. This is most apparent in text that runs over one line.

There are currently some limitations: clickable components will have incorrect clickable bounds, and talkback doesn't highlight components correctly.

Simple example of applying Modifier.curvedToEdge to text:

import androidx.compose.ui.Modifier
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.curveToEdge

Text("Curved Text", Modifier.curveToEdge())

Example of applying Modifier.curvedToEdge to a long piece of text, with overflow handling:

import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextOverflow
import androidx.wear.compose.material3.CurvedTextDefaults
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.curveToEdge

Text(
    "A really long piece of curved text",
    Modifier.curveToEdge(CurvedTextDefaults.StaticContentMaxSweepAngle),
    overflow = TextOverflow.Ellipsis,
    maxLines = 1,
)
Parameters
maxSweepAngle: Float = CurvedTextDefaults.ScrollableContentMaxSweepAngle

The maximum sweep angle in degrees, CurvedTextDefaults.ScrollableContentMaxSweepAngle by default. For screens without scrollable content, CurvedTextDefaults.StaticContentMaxSweepAngle may be used instead.

angularDirection: AngularDirection = AngularDirection.Clockwise

Specify the direction of the content. Default is clockwise (so that text appears the correct way up while at the top of the container)

anchor: Float = 270.0f

The angle at which the content is laid out relative to, in degrees. An angle of 0 corresponds to the right (3 o'clock on a watch), 90 degrees is bottom (6 o'clock), and so on. Default is 270 degrees (top of the container).

anchorType: AngularAnchorType = AngularAnchorType.Center

Specify how the content is drawn with respect to the anchor. Default is to center the content on the anchor.