的活动:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.andre.myapplication.MainActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:minHeight="?attr/actionBarSize"
style="@style/ToolbarTheme">
</android.support.v7.widget.Toolbar>
</LinearLayout>
styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="ToolbarTheme" parent="ThemeOverlay.AppCompat.Light">
<item name="android:textColorPrimary">@android:color/white</item>
<item name="android:textColorSecondary">@android:color/white</item>
<item name="android:textColor">@android:color/white</item>
</style>
</resources>
但我仍然在工具栏上有黑色标题。为什么?
答案 0 :(得分:0)
您可以尝试将textColor直接设置为工具栏。如果它有效,主题中会发生一些奇怪的事情
答案 1 :(得分:0)
<style name="ToolbarTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
当我想要工具栏中的白色标题时,这对我有用