Status Bar Color not changing with Relative Layout as root element

后端 未结 3 1851
耶瑟儿~
耶瑟儿~ 2020-12-17 15:48

I am just starting to learn android, I am learning to add AppBar. But if I use Relative Layout as the root then Status Bar don\'t use the color \"colorPrimaryDark\" defined

相关标签:
3条回答
  • 2020-12-17 16:01

    In v21/styles.xml you probably have this line of code:

      <item name="android:statusBarColor">@android:color/transparent</item>
    

    And as you are running on API 23, the declared styles are overrided from the ones in v21/styles.xml.

    As a solution:

    Just remove that line and it will work fine

    0 讨论(0)
  • 2020-12-17 16:10

    just add this

    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    
    0 讨论(0)
  • 2020-12-17 16:11

    The styling of the statusbar is done by the

    android:fitsSystemWindows
    

    tag. This is currently not supported for RelativeLayout. Either you try another layout like FrameLayout which could work but for know i would suggest to stick to the CoordinatorLayout.

    Maybe you get some more details here: https://medium.com/google-developers/why-would-i-want-to-fitssystemwindows-4e26d9ce1eec

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