在colors.xml替換這些值
<color name="colorPrimary">#101010</color>
<color name="colorPrimaryDark">#000000</color>
這將是足以改變工具欄的顏色。
如果你不想改變整個應用程序,主要顏色(這似乎是你試圖在第一個地方做),試圖通過創建一個新的工具欄:
添加這個應用程式的的build.gradle
compile 'com.android.support:design:23.1.1'
添加到您的主要佈局(activity_main.xml中)
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="mx.evin.apps.startingtemplate.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/a_main_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/black"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
設置這在您的樣式(styles.xml):
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
並設置新的工具欄(MainActivity.java)。
Toolbar toolbar = (Toolbar) findViewById(R.id.a_main_toolbar);
setSupportActionBar(toolbar);
thnx男人這兩種技術的工作! –