Anand
Anand

Reputation: 1959

Xamarin.forms android change software back button layout background color

How can I change the software back button layout color at the bottom for xamarin.forms android app? It only shows white color. If we open google photos app we can see that the color is managed. Please refer the images.

1. Xamarin.forms android app with white background for software back button

enter image description here

2. Google Photos app with dark color for software back button layout.

enter image description here

How can we change the color? Any Help is appreciated.

Upvotes: 0

Views: 415

Answers (2)

Leo Zhu
Leo Zhu

Reputation: 14956

If your Api version is Level 21 or above (Android 5.0 and above).You could use SetNavigationBarColor method to set the background color.

protected override void OnCreate(Bundle savedInstanceState)
    {
        TabLayoutResource = Resource.Layout.Tabbar;
        ToolbarResource = Resource.Layout.Toolbar;

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

        base.OnCreate(savedInstanceState);
         
        ...
   }

Upvotes: 1

Woj
Woj

Reputation: 833

You have to change the Theme of Android app.

tutorial here.

https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/theming/theming

Upvotes: 1

Related Questions