但是,我正在實現自己的工具欄/操作欄,狀態欄顏色變爲棕色,並且我試圖給它一個深藍色的默認值。我該如何改變這一點。我試圖玩弄style.xml主題,也是工具欄主題。但我不明白。任何幫助讚賞。 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>
</resources>
toolbar.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/my_toolbar"
android:popupTheme="@style/ThemeOverlay.AppCompat"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:paddingBottom="5dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
tools:context="com.example.com.mytoolbar.MainActivity" />
menu.xml文件
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- "Mark Favorite", should appear as action button if possible -->
<item
android:id="@+id/refresh"
android:icon="@drawable/ic_refresh_black_48dp"
android:title="@string/refresh"
app:showAsAction="ifRoom"/>
<!-- Settings, should always be in the overflow -->
<item android:id="@+id/settings"
android:title="@string/settings"
app:showAsAction="never"/>
</menu>
activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="vertical"
tools:context="com.example.com.mytoolbar.MainActivity">
<include layout="@layout/toolbar" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout>
嘗試從toolbar.xml中刪除popupTheme –