locked
How to change the color of Xamarin.Forms.NavigationPage RRS feed

  • Question

  • User61233 posted

    I wrote this, but it seems not working. public class App { public static Page GetMainPage () {
    var masterPage = new MasterPage (); var navigationPage = new NavigationPage (masterPage); navigationPage.BackgroundColor = Color.Red; return navigationPage; } }

    Monday, July 7, 2014 5:08 AM

All replies

  • User59097 posted

    you can try masterPage.BackgroundColor = youColor

    Monday, July 7, 2014 6:24 AM
  • User59097 posted

    you can try masterPage.BackgroundColor = youColor

    Monday, July 7, 2014 6:27 AM
  • User61233 posted

    @xiaoman? , thanks. To be honest, I'd like to change the color of the navigation bar instead of masterPage. In addition, I think it might be yourColor rather than youColor.

    : )

    Monday, July 7, 2014 12:08 PM
  • User56129 posted

    at the current moment, I have been reading that this isn't possible within forms easily, and in order to accomplish this, you would need to write a custom renderer. the way I was able to accomplish this was to just hide the default navigation bar, create a colored bar that I displayed at the top of the screen, and finally added my own buttons to handle navigation.

    Monday, July 7, 2014 2:40 PM
  • User61233 posted

    @Marshall? Thanks

    Monday, July 7, 2014 2:50 PM
  • User60243 posted

    u can do it this way.

    public class App { public static Page GetMainPage () {

            var navigationPage = new NavigationPage (new masterPage())
    
            {Tint=Color.Red,};
            return navigationPage;
        }
    }
    
    Monday, July 7, 2014 8:43 PM
  • User62552 posted

    Thank you!

    Tuesday, July 8, 2014 7:26 AM
  • User61233 posted

    @MiniyahilArekew? Thanks. But when it running on Android, the color is not pure. How could I set the pure color?

    Wednesday, July 9, 2014 12:40 AM
  • User60243 posted

    Are u saying the android back Icon?

    Wednesday, July 9, 2014 5:59 PM
  • User56129 posted

    @MiniyahilArekew? He is talking about making the navigation bar a solid color, the way iOS makes it a solid color, rather than having the gradient that it has.

    Wednesday, July 9, 2014 6:30 PM
  • User60243 posted

    oh..that is because both platforms use their native controls to rendered the navigation bar. I was struggled with this before. I sort it out by making custom navigation bar and then hide the default navigation bar on the page. The custom navigation bar will be on the top of the stack layout to show the bar at the top of the screen.

    Wednesday, July 9, 2014 7:19 PM
  • User61233 posted

    @Marshall? @MiniyahilArekew? , Thanks. I found that the navigation bar of MobileCRM on Android is solid color, I read the code but could not find how to do. Could you tell me about that? It seems that it doesn't make a custom navigation bar or use a custom render.

    Thursday, July 10, 2014 12:30 AM
  • User63571 posted

    Hey everyone, I did it like this:

        public static INavigation Navigation {get; private set; }
    
        public static Page GetMainPage ()
        {
            var rootPage = new NavigationPage(new SignInController());
    
            Navigation = rootPage.Navigation;
            rootPage.BarBackgroundColor = Color.Black;
            rootPage.BarTextColor = Color.FromHex(AppColors.GRAY);
    
            return rootPage;
        }
    
    Tuesday, August 5, 2014 7:31 PM
  • User67803 posted

    @DaohanChong? MobileCRM does define a native Android Theme via /Properties/AndroidManifest.xml (android:theme="@style/MyTheme"), the theme itself is setup in /Resources/values/styles_basetheme.xml

    Thursday, August 14, 2014 1:09 PM