英文:
fontWeight attribute not working in Jetpack Compose
问题
我正在尝试在Jetpack Compose中设置文本的字体粗细,但它没有任何效果。
我可以在预览中看到变化,但在运行应用程序时没有任何变化。
我已经尽可能地更新了一切。
例如,即使是最简单的文本字体粗细更改也不起作用:
Text(
fontWeight = FontWeight(800),
text = "文本示例",
)
我还尝试将fontWeight放在text属性之后 - 结果相同。
可能的问题是什么?谢谢。
英文:
I am trying to set the font-weight of a text in Jetpack Compose and it's just not doing any effect.
I can see the change in the preview, but nothing changes when I run the app.
I updated everything possible.
for example, even the simplest text font weight change isn't working:
Text(
fontWeight = FontWeight(800),
text = "Text Example",
)
I've also tried putting the fontWeight after the text attribute — the same result.
What could be the problem? Thank you.
答案1
得分: 1
Clean and Rebuild the project.
So your code will work perfectly
Font weight can be in the range [1 to 1000]
Text(text = "Text Example", fontWeight = FontWeight(800))
英文:
Clean and Rebuild the project.
So your code will work perfectly
> Font weight can be in the range [1 to 1000]
Text(text = "Text Example", fontWeight = FontWeight(800))
答案2
得分: 0
这可能有效吗?
Text(
text = "文本示例",
style = TextStyle(
fontWeight = FontWeight(800)))
英文:
Maybe this would work?
Text(
text = "Text Example",
style = TextStyle(
fontWeight = FontWeight(800)))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论