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相关问答推荐

合成 colored颜色 的GSON反序列化

使用Retrofit2的API调用:我如何能够一直进行API调用,以更新数据而无需重新打开应用程序

在Android上使用XSLT文件转换XML文件

为什么 Android Compose 将片段作为参数传递给 Composables 函数?

AndroidX Media3 迁移指南

升级到 Jetpack Compose 物料 list 2023.08.00 需要我将 targetSdk 更改为 34

kotlin中&&和and的区别

如何在C++中使用JNI_GetCreatedJavaVMs调用Java代码

CoroutineScope 与挂起函数

获取 ArithmeticException:除以零,但我没有在任何地方除以零

Jetpack Compose 部分或开放侧边框

如何在 BottomBar jetpack compose 中删除选定的椭圆项目 colored颜色

Jetpack compose 为网络检索视频帧导致延迟

JCenter 是否永久关闭(10 月 31 日)?

使用 capacitor cordova 插件的 Android Studio 错误

如何在 TextButton 中分隔文本和图标

如何删除 Ktor 客户端 2.0.0 的默认标头

自定义布局忽略可组合的大小

AndroidX Room 生成类错误:类是公共的,应在名为 class.java 的文件中声明

带有 GET_SIGNING_CERTIFICATES 的 PackageManager.getPackageArchiveInfo 返回空签名信息