【问题标题】:Change only background and color of titlebar仅更改标题栏的背景和颜色
【发布时间】:2015-01-29 01:03:05
【问题描述】:

我正在尝试自定义标题栏的背景和颜色。我在 android 网站上看到了很多示例和堆栈溢出,但对我来说没有任何效果。

在示例中,他们在标题栏中添加了新元素,但我想自定义现有的标题栏。

我不想更改任何其他内容。我只想更改文本的背景颜色和字体颜色。

【问题讨论】:

标签: android android-actionbar android-titlebar


【解决方案1】:

如果您使用的是 Android Lollipop (api 21+),您可以编辑“styles21.xml”(在 res 目录中)代码并添加以下内容:

<?xml version="1.0" encoding="utf-8"?>

<resources>
    <style name="AppTheme" parent="android:Theme.Material">
        <!-- Customize your theme using Material Design here. -->
        <!-- Title Bar color here -->
        <item name="android:colorPrimary">#YOUR_COLOR_HERE</item>
        <!-- Background color here -->
        <item name="android:windowBackground">#YOUR_COLOR_HERE</item>
    </style>
</resources>

欲了解更多信息,请参阅Google's "Using the Material Theme" here.

除非另有说明,否则此 XML 代码将在整个应用程序(每个不同的视图)中运行。

我希望这就是你要找的东西!

【讨论】:

  • 如何决定父母的意思是我的父母?
  • 父主题是您希望使用的主题。要查看有关主题的更多信息,请访问我的答案中的链接。 (有 3 种不同的主题可用)
猜你喜欢
  • 2010-11-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多