当一个人应该使用Theme.AppCompat VS ThemeOverlay.AppCompat?个人、Theme、AppCompat、VS

2023-09-05 07:38:08 作者:寂寞ヾ刚刚好

有以下Theme.AppCompat类:

There are the following Theme.AppCompat classes:

Theme.AppCompat
Theme.AppCompat.Light
Theme.AppCompat.Light.DarkActionBar
Theme.AppCompat.NoActionBar
Theme.AppCompat.Light.NoActionBar
Theme.AppCompat.DialogWhenLarge
Theme.AppCompat.Light.DialogWhenLarge
Theme.AppCompat.Dialog
Theme.AppCompat.Light.Dialog
Theme.AppCompat.CompactMenu

和以下ThemeOverlay.AppCompat类:

and the following ThemeOverlay.AppCompat classes:

ThemeOverlay.AppCompat
ThemeOverlay.AppCompat.Light
ThemeOverlay.AppCompat.Dark
ThemeOverlay.AppCompat.ActionBar
ThemeOverlay.AppCompat.Dark.ActionBar

为什么总会有使用ThemeOverlay.AppCompat.light VS Theme.AppCompat.Light例如?我看到有对ThemeOverlay定义的少得多的属性 - 我很好奇的预期使用情况下ThemeOverlay是什么

Why would one use ThemeOverlay.AppCompat.light vs Theme.AppCompat.Light for example? I see that there are much less attributes defined for ThemeOverlay -- I am curious what the intended use case for ThemeOverlay is.

推荐答案

每本主题VS风格博客文章通过AppCompat的创建者:

Per this Theme vs Style blog post by the creator of AppCompat:

[ThemeOverlays]是特殊题材而覆盖正常Theme.Material主题,覆盖相关的属性,使他们无论是亮/暗。

[ThemeOverlays] are special themes which overlay the normal Theme.Material themes, overwriting relevant attributes to make them either light/dark.

ThemeOverlay +动作条

你的敏锐的眼睛也已经看到了动作条ThemeOverlay衍生物:

The keen eyed of you will also have seen the ActionBar ThemeOverlay derivatives:

   ThemeOverlay.Material.Light.ActionBar    ThemeOverlay.Material.Dark.ActionBar    ThemeOverlay.Material.Light.ActionBar ThemeOverlay.Material.Dark.ActionBar

这些只能通过新的 actionBarTheme 属性中使用的操作栏,或直接设置工具栏上。

These should only be used with the Action Bar via the new actionBarTheme attribute, or directly set on your Toolbar.

唯一的东西,这些目前做不同他们的父母,他们修改 colorControlNormal 安卓textColorPrimary ,从而使任何文字和图标不透明的。

The only things these currently do differently to their parents is that they change the colorControlNormal to be android:textColorPrimary, thus making any text and icons opaque.