Changing the background color of the Toolbar

MAJosephMAJoseph Member ✭✭

I'm using the following code for change the background color of the toolbar. It working fine with the simulator. After converting it to APK the background color is not shown. Please help me to find out the result.

Best Answer

  • MAJosephMAJoseph ✭✭
    Accepted Answer

    Thanks @Leijae I got the solution actually the project was created an year ago. So it was old version project. So only some compatibility issues were occured. So now I've created a new project. Thanks

Answers

  • LeijaeLeijae Member ✭✭

    I don't see any of your code, but I use

        <Style TargetType ="NavigationPage">
            <Setter Property="BarBackgroundColor" Value="#7698f3"></Setter>
            <Setter Property="BarTextColor" Value="#ffffff"></Setter>
        </Style>
    
  • MAJosephMAJoseph Member ✭✭

    @Leijae It's working with my simulator. Once i build the APK and install it.. It doesn't work

  • LeijaeLeijae Member ✭✭

    From this thread, https://forums.xamarin.com/discussion/95943/how-to-change-navigation-bar-background-color-for-each-content-page

    What happens if you use

        ((NavigationPage)Application.Current.MainPage).BarBackgroundColor = Color.Black;
                ((NavigationPage)Application.Current.MainPage).BarTextColor = Color.OrangeRed;
    

    in your page constructor?

  • MAJosephMAJoseph Member ✭✭
    edited July 9

    @Leijae It produces the following exception. System.NullReferenceException: Object reference not set to an instance of an object. At the first line. This is line...((NavigationPage)Application.Current.MainPage).BarBackgroundColor = Color.Black;

  • MAJosephMAJoseph Member ✭✭

    Sorry ignore my last comment. Only the BarTextColor is working . BarBackgroundColor is not working

  • MAJosephMAJoseph Member ✭✭
    Accepted Answer

    Thanks @Leijae I got the solution actually the project was created an year ago. So it was old version project. So only some compatibility issues were occured. So now I've created a new project. Thanks

  • LeijaeLeijae Member ✭✭

    glad you got it worked out. actually my next quest was going to be, what version of xf are you on

  • MAJosephMAJoseph Member ✭✭

    Here it is.

Sign In or Register to comment.