我有一个布局,用于根据colorPrimaryDark更新状态栏的背景颜色.当布局的根布局是CoordinatorLayout时,这样做很好,但是当我将其切换到线性布局时,状态栏背景不再更新.
布局的来源和屏幕截图被粘贴在下面.还列出了正常工作的布局示例.
谢谢!
layout.xml
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=".churches.ChurchesActivity">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
android:id="@+id/contentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
styles.xml
@color/colorPrimary
@color/colorPrimaryDark
@color/colorAccent
false
true
款式 – v21.xml
false
true
true
@android:color/transparent
状态栏不是colorPrimaryDark
状态栏是colorPrimaryDark