1// for my fellow react-native developers
2// add this in styles.xml
3<resources>
4 <!-- Base application theme. -->
5 <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
6 <!-- Customize your theme here. -->
7 <item name="android:textColor">#000000</item>
8 <item name="android:windowDisablePreview">true</item>
9 <item name="android:windowBackground">#000000</item>
10 <item name="android:colorBackground">#000000</item>
11 <item name="android:statusBarColor">#000000</item>//<--add_this
12 </style>
13
14</resources>
1 public void statuscolor(){
2 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
3 Window window = getWindow();
4 window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
5 window.setStatusBarColor(Color.parseColor(getPreferences().getString(Constant.SECONDARY_COLOR, Constant.SECONDARY_COLOR)));
6 }
7 }
1Window window = activity.getWindow();
2
3// clear FLAG_TRANSLUCENT_STATUS flag:
4window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
5
6// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
7window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
8
9// finally change the color
10window.setStatusBarColor(ContextCompat.getColor(activity,R.color.my_statusbar_color));
1WindowInsetsControllerCompat(<window>, <view>).isAppearanceLightStatusBars = Boolean
2Window window = Activity.getWindow();
3View view = window.getDecorView();
4
5// You need androidx.core for this
1if (Build.VERSION.SDK_INT >= 21) {
2 Window window = this.getWindow();
3 window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
4 window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
5 window.setStatusBarColor(this.getResources().getColor(R.color.colorPrimaryDark));
6 }
7