本文介绍了带有浅色应用程序主题的深色工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I know this question has been asked before, and it worked for me before but after updating to App Compat revision 23, the Toolbar is now having a black text color (I want it white) and I didn't change a thing.

工具栏.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>

styles.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>

将工具栏设置为活动:

 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"

这篇关于带有浅色应用程序主题的深色工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 17:18