android - 带有浅色应用程序主题的深色工具栏

标签 android android-support-library android-appcompat

我知道这个问题之前已经被问过,它之前对我有用,但在更新到 App Compat 修订版 23 后,工具栏现在有黑色文本颜色(我想要它白色),我没有改变任何东西.

工具栏.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    >

</android.support.v7.widget.Toolbar>

样式.xml

<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="@attr/spinner_style">@style/spinner_style</item>
</style>

将工具栏设置为 Activity :

 Toolbar Toolbar = (Toolbar) AppCompatActivity.findViewById(R.id.toolbar);
 AppCompatActivity.setSupportActionBar(Toolbar);
 ActionBar actionBar = ((AppCompatActivity)activity).getSupportActionBar();
 actionBar.setTitle(title);

最佳答案

改变

local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"

android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"

关于android - 带有浅色应用程序主题的深色工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33101818/

相关文章:

android - 如何在android中以编程方式录制我的应用程序屏幕的视频

android设置没有改变

android - 如何找到目标 SDK 的最新支持库版本?

Android Studio 奇怪的警告

Android:无法解析 appcompat-v7 主题

android - 使用 appcompat 更改操作栏菜单字体颜色

android - 从计算机使用 adb 向 Android 设备发送通知消息

android - 约束布局 : Compound ImageView that stays in parent when text expands

java - Android studio,AppCompatButton的子类不像按钮

android - 无法获取在 ExpandableListView 中编辑文本中输入的字符串(不是通常的 Focus 问题)