Change Status Bar Text Color Android Programmatically Code Example


Example 1: change status bar text color android programmatically

WindowInsetsControllerCompat(<window>, <view>).isAppearanceLightStatusBars = Boolean Window window = Activity.getWindow(); View view = window.getDecorView();  // You need androidx.core for this

Example 2: change status bar color android programmatically

public void statuscolor(){         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {             Window window = getWindow();             window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);             window.setStatusBarColor(Color.parseColor(getPreferences().getString(Constant.SECONDARY_COLOR, Constant.SECONDARY_COLOR)));         }     }

Example 3: change status bar color android

// for my fellow react-native developers // add this in styles.xml <resources>     <!-- Base application theme. -->     <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">         <!-- Customize your theme here. -->         <item name="android:textColor">#000000</item>         <item name="android:windowDisablePreview">true</item>         <item name="android:windowBackground">#000000</item>         <item name="android:colorBackground">#000000</item>         <item name="android:statusBarColor">#000000</item>//<--add_this     </style>  </resources>

Example 4: statusbar text color android

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);//  set status text dark  getWindow().setStatusBarColor(ContextCompat.getColor(MainActivity.this,R.color.colorPrimaryDark));// set status background white

Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?