“fontWeight”属性在Jetpack Compose中不起作用。

huangapple go评论61阅读模式
英文:

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)))

huangapple
  • 本文由 发表于 2023年5月13日 23:27:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76243522.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定