I am creating my own action bar with menu items and therefore using Theme.AppCompat.Light.NoActionBar
.
I want to have the action bar purple and the title color white, but at the moment it is black.
<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>
my action bar xml is:
<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"
>
As explained in this Google+ pro-tip, you can use a ThemeOverlay
to customize only certain things. This is useful for when you need to make text light on a dark background, which can be achieved by adding android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
to your Toolbar
:
<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"
>
This technique was further discussed in the Theming with AppCompat blog+video.