gpt4 book ai didi

android - 为什么 Jetpack Compose 不将按钮中的文本大写?

转载 作者:行者123 更新时间:2023-12-04 11:28:15 26 4
gpt4 key购买 nike

文档似乎认为按钮应该全部大写 https://developer.android.com/reference/kotlin/androidx/compose/material/Typography#button但实际上并非如此。 (使用 1.0.0-beta01)
如何更改我的主题以使按钮文本大写?

最佳答案

TextStyle 类中似乎还没有允许您设置大写的属性。
我发现的唯一解决方法是为 button 修改我的 Typography 主题。并使用 fontFeatureSettings TextStyle 的属性(property)使用 fontFeatureSettings = "c2sc, smcp" 为所有字符设置小型大写字母
示例 Typography.kt

val Typography = Typography(
button = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.W500,
fontSize = 16.sp,
fontFeatureSettings = "c2sc, smcp"
)
)
从文档

The advanced typography settings provided by font. The format is the same as the CSS font-feature-settings attribute: https://www.w3.org/TR/css-fonts-3/#font-feature-settings-prop


来自 CSS font-variant Property 的注释

In a small-caps font, all lowercase letters are converted to uppercase letters. However, the converted uppercase letters appears in a smaller font size than the original uppercase letters in the text.


不是一个非常漂亮的解决方案,但它是一些东西。
1.1.0-alpha01 测试

关于android - 为什么 Jetpack Compose 不将按钮中的文本大写?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66550091/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com