如何更改状态栏的颜色?

时间:2016-03-12 04:46:11

标签: android xml android-layout android-actionbar

我添加了一个CollapsingToorbar,保留android:foreground=#bd1212。但当它崩溃时,状态栏颜色成为默认颜色。 有人可以告诉我如何更改状态栏的颜色?

1 个答案:

答案 0 :(得分:0)

您正在寻找属性“contentScrim”:

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/place_activity_coordinator"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFF">
        ...
        ...
    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/place_activity_collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="#8000" <!-- This color is what you need to change -->
        app:expandedTitleTextAppearance="@style/collapsing_toolbar_expanded"
        app:collapsedTitleTextAppearance="@style/collapsing_toolbar_collapsed"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">