This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OptIn(ExperimentalTextApi::class) | |
@Composable | |
fun ExampleTextOverFlow() { | |
val textMeasure = rememberTextMeasurer() | |
Canvas( | |
onDraw = { | |
drawRect(color = Color.Black) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OptIn(ExperimentalTextApi::class) | |
@Composable | |
fun ExampleTextLayoutResult() { | |
val textMeasure = rememberTextMeasurer() | |
var textLayoutResult by remember { mutableStateOf<TextLayoutResult?>(null) } | |
Canvas( | |
modifier = Modifier | |
.fillMaxWidth() | |
.height(100.dp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val textMeasure = rememberTextMeasurer() | |
var textLayoutResult by remember { mutableStateOf<TextLayoutResult?>(null) } | |
Canvas( | |
modifier = Modifier | |
.layout { measurable, constraints -> | |
val placeable = measurable.measure(constraints) | |
textLayoutResult = textMeasure.measure( | |
AnnotatedString("Text on Canvas!"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ExperimentalTextApi | |
fun DrawScope.drawText( | |
textLayoutResult: TextLayoutResult, | |
color: Color = Color.Unspecified, | |
topLeft: Offset = Offset.Zero, | |
alpha: Float = Float.NaN, | |
shadow: Shadow? = null, | |
textDecoration: TextDecoration? = null | |
){} | |
@ExperimentalTextApi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun ExampleTextString() { | |
val textMeasure = rememberTextMeasurer() | |
Canvas(modifier = Modifier | |
.fillMaxWidth() | |
.height(100.dp), onDraw = { | |
drawRect(color = Color.Black) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ExperimentalTextApi | |
fun DrawScope.drawText( | |
textMeasurer: TextMeasurer, | |
text: String, | |
// Other configuration | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OptIn(ExperimentalTextApi::class) | |
@Composable | |
fun ExampleTextAnnotatedString() { | |
val textMeasure = rememberTextMeasurer() | |
val text = buildAnnotatedString { | |
withStyle( | |
style = SpanStyle( | |
color = Color.White, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun DrawScope.drawText( | |
textMeasurer: TextMeasurer, | |
text: AnnotatedString, | |
// other configuration... | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun NativeDrawText() { | |
val paint = Paint().asFrameworkPaint().apply { | |
// paint configuration | |
} | |
Canvas(modifier = Modifier | |
.fillMaxWidth() | |
.height(100.dp), onDraw = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun NoRippleEffect3() { | |
CompositionLocalProvider(LocalRippleTheme provides NoRippleTheme) { | |
Button( | |
onClick = { | |
//Clicked | |
}, shape = RoundedCornerShape(12.dp), | |
contentPadding = PaddingValues(16.dp) | |
) { | |
Text(text = "Click me") |
NewerOlder