change status bar color android code example
Example 1: 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 2: status bar color android kotlin
Window window = activity.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ContextCompat.getColor(activity,R.color.my_statusbar_color));
Example 3: change status bar color android
<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>
</style>
</resources>