I am seeking guidance on efficiently utilizing color schemes. While we understand that MaterialTheme.colorScheme allows us to apply colors uniformly across various components, I'm curious if there are specific recommendations for leveraging each aspect of the color scheme. For instance, what is the ideal use case for the primary color?
How about the onPrimary color?
And what role does the primaryContainer color serve?

以下是所有配色方案属性:

ColorScheme(
    primary: Color,
    onPrimary: Color,
    primaryContainer: Color,
    onPrimaryContainer: Color,
    inversePrimary: Color,
    secondary: Color,
    onSecondary: Color,
    secondaryContainer: Color,
    onSecondaryContainer: Color,
    tertiary: Color,
    onTertiary: Color,
    tertiaryContainer: Color,
    onTertiaryContainer: Color,
    background: Color,
    onBackground: Color,
    surface: Color,
    onSurface: Color,
    surfaceVariant: Color,
    onSurfaceVariant: Color,
    surfaceTint: Color,
    inverseSurface: Color,
    inverseOnSurface: Color,
    error: Color,
    onError: Color,
    errorContainer: Color,
    onErrorContainer: Color,
    outline: Color,
    outlineVariant: Color,
    scrim: Color
)

也许有人有一个使用它的指导方针?

谢谢

推荐答案

总之,

Role Explanation
Surface A role used for backgrounds and large, low-emphasis areas of the screen.
Primary,
Secondary,
Tertiary
Accent color roles used to emphasize or de-emphasize foreground elements.
Container Roles used as a fill color for foreground elements like buttons. They should not be used for text or icons.
On Roles starting with this term indicate a color for text or icons on top of its paired parent color. For example, on primary is used for text and icons against the primary fill color.
Variant Roles ending with this term offer a lower emphasis alternative to its non-variant pair. For example, outline variant is a less emphasized version of the outline color.
Inverse Inverse roles are applied selectively to components to achieve colors that are the reverse of those in the surrounding UI, creating a contrasting effect.

详细信息,请阅读this

Android相关问答推荐

ArrayList.remove()(Kotlin中的removeAt())导致奇怪的IndexOutOfBoundsResponse异常

无法理解Kotlin Coroutines and Flows中的J.C.编程行为

在Android Studio中陷入了不兼容的Gradle版本的循环

编写Landscape BoxWithRequests具有错误的高度.(aspectRatio matchHeight约束第一次未按预期工作)

如何在"不同活动"中添加不同按钮?

房间@嵌入式VS一对一关系

如何从sqlite数据库中检索数据到碎片android?

使用Jetpack Compose创建特定于电视的布局

错误:无法安装应用程序:INSTALL_PARSE_FAILED_MANIFEST_MALFORMED (React-Native-Android-Studio)

如何在一个活动中预加载图像然后在另一个活动中加载它们?

如何以编程方式通过 whatsapp android 共享图像和文本

我该怎么做文本计时器

每次在 Jetpack Compose 中调用导航

错误:构建 react-native 应用程序时包 com.facebook.react.bridge 不存在

无法 HEAD 'https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml'

如何修复 api 调用在浏览器中工作但在 android studio 中为 403

Android:为什么 ICICI iMobile Pay 应用程序在我的应用程序中显示root/jailbroken设备?

如何在包含 Jetpack Compose 内容的布局中使用权重

升级到 android studio 花栗鼠后,应用程序未安装在模拟器中

如何获取 Android Preferences DataStore 的所有键