Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How to change backgroundcolor of actionbar

$
0
0

Hi guys!

I can't get my head around the following issue after reading a lot about this. My app has got an hamburger-menu and two additional buttons in the actionbar. The problem is (as you can see in the screenshot below) that the actionbar isn't taking the same (green-ish) backgroundcolor as the rest of the app.

From what I learned after several attempts and spending several hours of investigating this issue, is that I need to use a navigationpage as a mainpage in my App.xaml.cs. So I've done that;

public App()
        {
            InitializeComponent();

            if (IsLoggedIn())
            {
                //MainPage = new MainPage();
                MainPage = new NavigationPage(new MainPage());
                //MainPage = new NavigationPage(new MainPage()) { BarBackgroundColor = Color.FromHex("#55BBAB"), BarTextColor = Color.FromHex("#FFF") };                
            }
            else
            {
                //MainPage = new LoaderPage();
                MainPage = new SignIn();
            }
        }

After adding the line of code which instantiates the NavigationPage, I was suddenly stuck with two actionbars! I finally got this fixed by setting the option 'SetHasNavigationBar';

        public MainPage()
        {
            InitializeComponent();

            MasterBehavior = MasterBehavior.Popover;

            ////https://stackoverflow.com/questions/51824298/duplicate-xamarin-navbar-toolbar-items?rq=1           
            NavigationPage.SetHasNavigationBar(this, false);

            //MenuPages.Add((int)EMenuItemType.Browse, (NavigationPage)Detail);
        }

But whatever I try, I can't change the color of the actionbar / navigationbar. I tried suggestions similar to these;

But none of them seem to work. Is there anyone here who can help me out on this one? It's driving me nuts!


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>