Status bar turns white and does not show content behind it

前端 未结 26 2360
闹比i
闹比i 2020-11-29 22:33

I am trying out AppCompat on Marshmallow. And I want to have a transparent status bar however it turns white. I\'ve tried a couple solutions but they didn\'t work for me (Tr

相关标签:
26条回答
  • 2020-11-29 23:20

    My guess is that this is caused by your android:windowBackground. Is @color/background_material_light a reference to white?

    0 讨论(0)
  • 2020-11-29 23:21

    I faced the same issue. What i did was, in the "v21/styles.xml" file a changed the value true:

     <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    

    to:

     <item name="android:windowDrawsSystemBarBackgrounds">false</item>
    
    0 讨论(0)
  • 2020-11-29 23:23

    Just put this item in your v21\styles.xml :

    true

    It should look like this :

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:windowTranslucentStatus">true</item>
    </style>
    

    0 讨论(0)
  • 2020-11-29 23:23

    If you are using RelativeLayout / CoordinatorLayout this is the solution that worked for me:

    You have to use

    • CoordinatorLayout
    • AppBarLayout

    Rember to use CoordinatorLayout instead of RelativeLayout (the performance is better and perfectly works with AppBarLayout)

    This is how your fragment should starts

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout
    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="@android:color/background_light"
    android:fitsSystemWindows="true"
    >
    
    <android.support.design.widget.AppBarLayout
        android:id="@+id/main.appbar"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:fitsSystemWindows="true"
        >
        ...
    

    Good coding!

    0 讨论(0)
  • 2020-11-29 23:25

    For styles v23

     <style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowLightStatusBar">true</item>
        <item name="android:statusBarColor">@android:color/white</item>
    </style>
    

    For styles v21

    <style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:statusBarColor">@android:color/white</item>
    </style>
    
    0 讨论(0)
  • 2020-11-29 23:27
        Window window = this.getWindow();
        window.setStatusBarColor(this.getResources().getColor(R.color.colorPrimaryDark));
    

    Add this 2 line in java file below

    0 讨论(0)
提交回复
热议问题