Set the Status Bar to Black Colour

Set the status bar to black colour

For Xcode 8 / iOS 10 / Swift 3:

Change the status bar background color temporarily on one view by adding a colored UIView under the status bar. I put these lines in viewWillAppear(). my tint is white with 45% transparency, but you can put in any opaque or transparent UIColor value.

let statusView = UIView(frame: CGRect(x: 0, y: 0, width:     self.view.bounds.width, height: 20))
statusView.backgroundColor = UIColor.white.withAlphaComponent(0.45)
self.view.addSubview(statusView)

You can add your statusView to the navigationController, instead of the view, if you have a navigation controller on the view.

You can also pass in UIScreen.main.bounds.size.width for the width of the simulated status bar background view. Do not hardcode a width, otherwise it wont fit all devices properly.

Alternatively, you can also change the status bar background throughout your app using this code. be aware that if even if placed in viewWillAppear(), not viewDidLoad(), other views will still adopt the altered status bar when you navigate forward/back.

let statWindow = UIApplication.shared.value(forKey:"statusBarWindow") as! UIView
let statusBar = statWindow.subviews[0] as UIView
statusBar.backgroundColor = UIColor.white.withAlphaComponent(0.45)

How to change status bar color in Flutter?

Works totally fine in my app

import 'package:flutter_statusbarcolor/flutter_statusbarcolor.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
FlutterStatusbarcolor.setStatusBarColor(Colors.white);
return MaterialApp(
title: app_title,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: HomePage(title: home_title),
);
}
}

(this package)

UPD:
Recommended solution (Flutter 2.0 and above)

SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.white
));

How to change the status bar color in Android?

Update:

Lollipop:

public abstract void setStatusBarColor (int color)

Added in API level 21

Android Lollipop brought with it the ability to change the color of status bar in your app for a more immersive user experience and in tune with Google’s Material Design Guidelines.

Here is how you can change the color of the status bar using the new window.setStatusBarColor method introduced in API level 21.

Changing the color of status bar also requires setting two additional flags on the Window; you need to add the FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag and clear the FLAG_TRANSLUCENT_STATUS flag.

Working Code:

import android.view.Window;

...

Window window = activity.getWindow();

// clear FLAG_TRANSLUCENT_STATUS flag:
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

// finally change the color
window.setStatusBarColor(ContextCompat.getColor(activity,R.color.my_statusbar_color));

Offcial developer reference : setStatusBarColor(int)

Example :material-design-everywhere

Chris Banes Blog- appcompat v21: material design for pre-Lollipop devices!

Sample Image

The transitionName for the view background will be android:status:background.

how to change statusbar color in jetpack compose?

Google has just created a library called accompanist.

You can find it here: https://github.com/google/accompanist

It contains multiple helpful libraries for Jetpack Compose, among which is a System UI Controller that you can use for changing the status bar color.

Docs - https://google.github.io/accompanist/systemuicontroller/

How to set status bar icon color in Flutter?

Colour of status-bar icon is depend on color of appbar. You can try edit systemOverlayStyle of AppBar on Home Screen ?

https://api.flutter.dev/flutter/material/AppBar/systemOverlayStyle.html

Is it possible to change status bar icon color to white? Or is there a dark theme status bar? (Kotlin)

In your theme, set windowLightStatusBar to false -- and you can also set your status bar color in the theme:

<item name="android:statusBarColor">@color/black</item>
<item name="android:windowLightStatusBar">false</item>


Related Topics



Leave a reply



Submit