什么时候应该使用 Theme.AppCompat 与 ThemeOverlay.AppCompat? [英] When should one use Theme.AppCompat vs ThemeOverlay.AppCompat?

查看:60
本文介绍了什么时候应该使用 Theme.AppCompat 与 ThemeOverlay.AppCompat?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有以下 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 与 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.

推荐答案

Per this 主题 vsAppCompat 创建者的风格博客文章:

[ThemeOverlays] 是覆盖普通 Theme.Material 主题的特殊主题,覆盖相关属性使它们或亮/暗.

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

ThemeOverlay + ActionBar

敏锐的你也会看到 ActionBar ThemeOverlay 的衍生品:

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

  • 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 更改为 android: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.

这篇关于什么时候应该使用 Theme.AppCompat 与 ThemeOverlay.AppCompat?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆