【发布时间】:2019-10-23 14:42:54
【问题描述】:
状态栏和工具栏的显示方式如下:
工具栏的颜色必须延伸到状态栏的颜色,但我不明白这是怎么回事。
这是xml 的活动文件:
<RelativeLayout
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="wrap_content"
tools:context=".view.AmministratoreActivity">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar_amministratore"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:elevation="4dp"/>
</RelativeLayout>
在清单中,我对整个应用使用 android:theme="@style/AppTheme.NoActionBar
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:statusBarColor">@color/colorPrimaryDark</item>
</style>
</resources>
【问题讨论】:
-
清单中的主题是什么?你应该使用 android:theme="@style/AppTheme" tools:replace="android:theme"
标签: android android-toolbar android-statusbar