Nicke Manarin
Nicke Manarin

Reputation: 3358

Change the color of the top and bottom bar (ControlsBar, StatusBar) in a Xamarin.Forms app

Is there anyway, even if requires platform specific code behind, to change the color of both the top bar (the one in blue) and the bottom bar (the one in black)?

I wish to add support for light and dark modes, so I would like to be able to change that during runtime.

Android

Upvotes: 4

Views: 3224

Answers (2)

Suplanus
Suplanus

Reputation: 1601

Android

Build.VERSION_CODES.Lollipop is obsolete. Use Android.OS.BuildVersionCodes:

if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
{
  Window.SetStatusBarColor(Android.Graphics.Color.Orange;
  Window.SetNavigationBarColor(Android.Graphics.Color.Orange;
}

Upvotes: 1

Junior Jiang
Junior Jiang

Reputation: 12723

It is possible .

Android:

Using Window.SetStatusBarColor and Window.SetNavigationBarColor can do that easily above Android API 21.

  if (Build.VERSION.SdkInt >= Build.VERSION_CODES.Lollipop)
  {
       Window.SetStatusBarColor(Android.Graphics.Color.Orange);
       Window.SetNavigationBarColor(Android.Graphics.Color.Orange);
   }

enter image description here

IOS:

In ios, change navigation bar and status bar , can use as bellow:

NavigationController.NavigationBar.BarTintColor = UIColor.YouWantColor;
// Color you want, such as UIColor.Green

enter image description here

After click button, changed dynamically to green color.

enter image description here

Upvotes: 8

Related Questions