← Back to Wear Material
CurvedText
Overview
Code Examples
Video
CurvedText is a component allowing developers to easily write curved text following the curvature a circle (usually at the edge of a circular screen). CurvedText can be only created within the CurvedRow to ensure the best experience, like being able to specify to positioning.
The default style uses the LocalTextStyle provided by the MaterialTheme / components, converting it to a CurvedTextStyle. Note that not all parameters are used by CurvedText.
If you are setting your own style, you may want to consider first retrieving LocalTextStyle, and using TextStyle.copy to keep any theme defined attributes, only modifying the specific attributes you want to override, then convert to CurvedTextStyle
For ease of use, commonly used parameters from CurvedTextStyle are also present here. The order of precedence is as follows:
- If a parameter is explicitly set here (i.e, it is not
null
or TextUnit.Unspecified), then this parameter will always be used. - If a parameter is not set, (
null
or TextUnit.Unspecified), then the corresponding value from style will be used instead.
Additionally, for color, if color is not set, and style does not have a color, then LocalContentColor will be used with an alpha of LocalContentAlpha- this allows this CurvedText or element containing this CurvedText to adapt to different background colors and still maintain contrast and accessibility.
Overloads
CurvedText
@Composable
fun CurvedRowScope.CurvedText(
text: String,
modifier: Modifier = Modifier,
color: Color = Color.Unspecified,
background: Color = Color.Unspecified,
fontSize: TextUnit = TextUnit.Unspecified,
style: CurvedTextStyle = CurvedTextStyle(LocalTextStyle.current),
clockwise: Boolean = true,
contentArcPadding: ArcPaddingValues = ArcPaddingValues(0.dp),
)
Parameters
Name | Description |
---|---|
text | The text to display |
color | Color to apply to the text. If Color.Unspecified, and style has no color set, this will be LocalContentColor. |
fontSize | The size of glyphs to use when painting the text. See TextStyle.fontSize. |
style | Specified the style to use. |
background | The background color for the text. |
clockwise | The direction the text follows (default is true). Usually text at the top of the screen goes clockwise, and text at the bottom goes counterclockwise. |
contentArcPadding | Allows to specify additional space along each "edge" of the content in Dp see ArcPaddingValues |