为我的工具栏和应用设置样式时遇到问题

trouble styling my toolbar and app

我将我的应用切换为使用工具栏,现在看起来像这样:

我使用 material 颜色选择器来挑选颜色,所以我可以让它看起来更像这样:

我拥有的那些颜色的 xml 看起来像这样:

<color name="primary">#FF9800</color>
    <color name="primary_dark">#F57C00</color>
    <color name="primary_light">#FFE0B2</color>
    <color name="accent">#FFEB3B</color>
    <color name="primary_text">#212121</color>
    <color name="secondary_text">#727272</color>
    <color name="icons">#212121</color>
    <color name="divider">#B6B6B6</color>

我试过像这样把它扔进我的styles.xml,但是没有效果:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat">
        <item name="android:windowNoTitle">true</item>
        <item name="windowActionBar">false</item>

    </style>

    <color name="primary">#FF9800</color>
    <color name="primary_dark">#F57C00</color>
    <color name="primary_light">#FFE0B2</color>
    <color name="accent">#FFEB3B</color>
    <color name="primary_text">#212121</color>
    <color name="secondary_text">#727272</color>
    <color name="icons">#212121</color>
    <color name="divider">#B6B6B6</color>


</resources>

我的 xml 布局预定义了工具栏,但是当我去掉背景颜色时,它什么也没有:

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:minHeight="?attr/actionBarSize"
            android:background="#2196F3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        </android.support.v7.widget.Toolbar>

        <FrameLayout
            android:id="@+id/main"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1" />

    </LinearLayout>

    <ListView
        android:id="@+id/drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:divider="@android:color/white"
        android:background="@android:color/black"
        android:choiceMode="none"/>

</android.support.v4.widget.DrawerLayout>

您需要为您的主题设置颜色:

<style name="AppTheme" parent="Theme.AppCompat">
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primaryDark</item>
    <item name="colorAccent">@color/accent</item>
    <item name="android:textColorPrimary">@color/primary_text</item>
    <item name="android:textColorSecondary">@color/secondary_text</item>
</style>