Status bar turns white and does not show content behind it

前端 未结 26 2358
闹比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:09

    This has work to me

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
            }
    
    0 讨论(0)
  • 2020-11-29 23:10

    Just remove following tag from style v21 @android:color/transparent

    This works for me.

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

    I have found solution for this -

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:windowLightStatusBar">true</item>
    </style>
    

    add this into your style and it will work for api 21 or above.

    0 讨论(0)
  • 2020-11-29 23:12
     <style name="AppTheme.NoActionBar">
            <item name="windowActionBar">false</item>
            <item name="windowNoTitle">true</item>
            <item name="android:windowDrawsSystemBarBackgrounds">true</item>
            <item name="android:statusBarColor">@color/colorPrimaryDark</item>
        </style
    

    Just Replace this , statusBarColor should be your expected color and not TRANSPARENT

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

    I fixed my issue by changing my Activity layout from FrameLayout to RelativeLayout. Thanks everybody who tried to help!

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@android:color/transparent">
    
        <android.support.v4.view.ViewPager
          android:id="@+id/pager"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@color/theme_primary_dark"
          android:fitsSystemWindows="true" />
    
    </RelativeLayout>
    

    Try hierarchy-viewer or ViewInspector. These tools might help you.

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

    Check this Toolbar turns white - AppBar isn't drawn after being scrolled off screen

    https://code.google.com/p/android/issues/detail?id=178037#c19

    I'm using libraries 23.0.0. and the bug still occurs.

    Workaround for this is adding View that takes nearly no space and can be invisible. See the structure below.

    <android.support.v4.widget.NestedScrollView
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
    
    </android.support.v4.widget.NestedScrollView>
    
    <android.support.design.widget.AppBarLayout>
    
        <android.support.v7.widget.Toolbar
            app:layout_scrollFlags="scroll|enterAlways" />
    
        <android.support.design.widget.TabLayout
            app:layout_scrollFlags="scroll|enterAlways" />
    
        <View
            android:layout_width="match_parent"
            android:layout_height=".3dp"
            android:visibility="visible"/>
    
    </android.support.design.widget.AppBarLayout>
    

    This Questions on Stackoverflow.com refer to this bug too: CoordinatorLayout Toolbar invisible on enter until full height AppBarLayout - Layout sometimes invisible once it enters view (even if it's not entered)

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