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
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
just add this
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
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