gpt4 book ai didi

android - 使用 Theme.AppCompat.Light.NoActionBar 时如何更改标题颜色

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:36:07 27 4
gpt4 key购买 nike

我正在使用菜单项创建自己的操作栏,因此使用 Theme.AppCompat.Light.NoActionBar

我想要紫色的操作栏和白色的标题颜色,但目前它是黑色的。

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

我的操作栏 xml 是:

<android.support.v7.widget.Toolbar  
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:id="@+id/app_bar"
>

最佳答案

如本 Google+ pro-tip 中所述,您可以使用 ThemeOverlay 仅自定义某些内容。当您需要在深色背景上使文本变亮时,这很有用,这可以通过将 android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 添加到您的 来实现工具栏:

<android.support.v7.widget.Toolbar  
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:id="@+id/app_bar"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
>

此技术在 Theming with AppCompat blog+video 中得到了进一步讨论。 .

关于android - 使用 Theme.AppCompat.Light.NoActionBar 时如何更改标题颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36143066/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com