如何在jetpack compose中使文本变得太粗?

Jee*_*cha 6 android android-jetpack-compose android-compose-textfield

使用Jetpack Compose Text()时,我无法更改fontWeightmore thanFontWeight.W600FontWeight.W500. 除了这两个之外,没有像 、 等应用FontWeight.W700FontWeight.BoldFontWeight(550)试图创建太暗的文本,但根本无法实现。注意:我使用的是来自谷歌可下载字体的Roboto字体和.material theme 3

One example of text code:-

Text(
   modifier = Modifier.padding(top = 4.dp),
   text = "This should be too bold",
   style = MaterialTheme.typography.titleSmall,
   fontWeight = FontWeight.Black,
)
Run Code Online (Sandbox Code Playgroud)

Mik*_*ail 9

来自官方 Android Compose 文档

@Composable
fun BoldText() {
    Text("Hello World", fontWeight = FontWeight.Bold)
}
Run Code Online (Sandbox Code Playgroud)

如果您需要其他样式(来自Material Design 3 文档):

Text(
   text = "Hello World",
   style = MaterialTheme.typography.displayLarge,
   color = MaterialTheme.colorScheme.primary,
)
Run Code Online (Sandbox Code Playgroud)

您还可以尝试通过手动选择样式从Google Fonts下载字体Black 900

在此输入图像描述