Android 工具栏覆盖并在状态栏上投射阴影
我正在使用AppCompat在棒棒糖前的设备上进行材料设计的后端口。不知何故,支持Android 工具栏覆盖并在状态栏上投射阴影,android,material-design,android-appcompat,Android,Material Design,Android Appcompat,我正在使用AppCompat在棒棒糖前的设备上进行材料设计的后端口。不知何故,支持工具栏覆盖了状态栏,并在其上投射了一个阴影,就好像状态栏在工具栏后面一样。在我的Android 5.0.2手机上测试 代码如下: 活动布局 <android.support.design.widget.CoordinatorLayout android:id="@+id/base_root" android:layout_width="match_parent" android:la
工具栏
覆盖了状态栏
,并在其上投射了一个阴影,就好像状态栏在工具栏后面一样。在我的Android 5.0.2手机上测试
代码如下:
活动布局
<android.support.design.widget.CoordinatorLayout
android:id="@+id/base_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/base_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/PGTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/base_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/PGTheme.PopupOverlay"/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
Theme-v21
<style name="PGTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/base_color_2</item>
<item name="colorPrimaryDark">@color/base_color_1</item>
<item name="colorAccent">@color/base_color_2</item>
<item name="android:colorButtonNormal">@color/base_color_2</item>
<item name="android:textViewStyle">@style/PGTheme.TextView</item>
<item name="android:editTextStyle">@style/PGTheme.EditText</item>
<item name="android:buttonStyle">@style/PGTheme.Button</item>
</style>
<style name="PGTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
@颜色/底色\u颜色\u 2
@颜色/底色\u颜色\u 1
@颜色/底色\u颜色\u 2
@颜色/底色\u颜色\u 2
@style/PGTheme.TextView
@style/PGTheme.EditText
@样式/PGTheme.Button
假的
真的
真的
@android:彩色/透明
知道为什么会发生这种情况吗?在您的样式中删除statusBarColor:
<item name="android:statusBarColor">@android:color/transparent</item>
@android:color/transparent
所以你的主题是:
<style name="PGTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
假的
真的
真的
希望这能有所帮助。它能起作用。如果您希望状态栏是透明的,您可以按照本文操作(并将颜色替换为color.transparent):