如何在Jetpack Compose中使文本过于粗体?

4
在使用Jetpack Compose的Text()时,我无法将fontWeight更改为超过FontWeight.W600和FontWeight.W500。除了这两个之外,其他都不适用,例如FontWeight.W700、FontWeight.Bold、FontWeight(550)等。我试图创建太暗的文本,但根本无法实现。注意:我正在使用来自谷歌可下载字体的Roboto字体和material theme 3。
一个文本代码示例:
Text(
   modifier = Modifier.padding(top = 4.dp),
   text = "This should be too bold",
   style = MaterialTheme.typography.titleSmall,
   fontWeight = FontWeight.Black,
)

你有使用过buildAnnotatedString吗? - Vahid Garousi
为什么不使用fontWeight = FontWeight.Bold和较大的fontSize呢? - Hamid Reza
1个回答

5
官方Android Compose文档中得知:
@Composable
fun BoldText() {
    Text("Hello World", fontWeight = FontWeight.Bold)
}

如果你需要额外的样式(来自Material Design 3 documentation):
Text(
   text = "Hello World",
   style = MaterialTheme.typography.displayLarge,
   color = MaterialTheme.colorScheme.primary,
)

你还可以尝试从Google Fonts下载字体,手动选择样式黑体 900

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接