How do the colors in this sample application work?

NickprovsNickprovs ✭✭USMember ✭✭

Hi all,

In this Xamarin Master-Detail app, I can't find the colors of the master, detail, or nav bar anywhere. They're definitely not in the .xaml or .cs files Xamarin Forms project. And I don't see anywhere they would be specified in the Android project other than resource.designer.cs (but modifying this in my own project had no effect).

Any ideas?

I can't post links yet. But you can google "xamarin master detail application" and it'll be there. It's from Xamarin's tutorial on Master Detail.

Thanks for looking into this,

Nick

Answers

  • MdNaushadMdNaushad ✭✭✭ INMember ✭✭✭

    The colors of your Navbar is present in the App.xaml file. For generic usage.

         <Style TargetType="NavigationPage">
                        <Setter Property="BarBackgroundColor" Value="{StaticResource NavigationBarColor}" />
                        <Setter Property="BarTextColor" Value="{StaticResource NavigationTextColor}" />
        </Style>
    

    For Android it is present in Android > Resources > values > styles.xml
    For iOS you can set it in AppDelegate.cs
    Something like below:
    UINavigationBar.Appearance.BarTintColor = Color.FromHex("#F2F2F2").ToUIColor(); //bar background

  • NickprovsNickprovs ✭✭ USMember ✭✭
    edited October 2017

    @MdNaushad said:
    The colors of your Navbar is present in the App.xaml file. For generic usage.

         <Style TargetType="NavigationPage">
                        <Setter Property="BarBackgroundColor" Value="{StaticResource NavigationBarColor}" />
                        <Setter Property="BarTextColor" Value="{StaticResource NavigationTextColor}" />
        </Style>
    

    For Android it is present in Android > Resources > values > styles.xml
    For iOS you can set it in AppDelegate.cs
    Something like below:
    UINavigationBar.Appearance.BarTintColor = Color.FromHex("#F2F2F2").ToUIColor(); //bar background

    Thanks, that was really informative.

    But this sample project does not have a styles.xml. And I'm fairly certain it's not using any of the default colors. Additionally, it doesn't have an App.Xaml. It specifies everything in an App.cs file. And I don't see anything to do with color or styles there.

    Any ideas?

  • MdNaushadMdNaushad ✭✭✭ INMember ✭✭✭
    > @Nickprovs said:
    > @MdNaushad said:
    > The colors of your Navbar is present in the App.xaml file. For generic usage.
    >
    >
    >
    > For Android it is present in Android > Resources > values > styles.xml
    > For iOS you can set it in AppDelegate.cs
    > Something like below:
    > UINavigationBar.Appearance.BarTintColor = Color.FromHex("#F2F2F2").ToUIColor(); //bar background
    >
    >
    >
    >
    >
    > Thanks, that was really informative.
    >
    > But this sample project does not have a styles.xml. And I'm fairly certain it's not using any of the default colors. Additionally, it doesn't have an App.Xaml. It specifies everything in an App.cs file. And I don't see anything to do with color or styles there.
    >
    > Any ideas?

    Can you post the link for the sample project or upload it on github?
  • NickprovsNickprovs ✭✭ USMember ✭✭
    edited October 2017

    @MdNaushad said:
    > @Nickprovs said:
    > @MdNaushad said:
    > The colors of your Navbar is present in the App.xaml file. For generic usage.
    >
    >
    >
    > For Android it is present in Android > Resources > values > styles.xml
    > For iOS you can set it in AppDelegate.cs
    > Something like below:
    > UINavigationBar.Appearance.BarTintColor = Color.FromHex("#F2F2F2").ToUIColor(); //bar background
    >
    >
    >
    >
    >
    > Thanks, that was really informative.
    >
    > But this sample project does not have a styles.xml. And I'm fairly certain it's not using any of the default colors. Additionally, it doesn't have an App.Xaml. It specifies everything in an App.cs file. And I don't see anything to do with color or styles there.
    >
    > Any ideas?

    Can you post the link for the sample project or upload it on github?

    I can post links now.

    https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/navigation/master-detail-page/

  • MdNaushadMdNaushad ✭✭✭ INMember ✭✭✭

    The link that you have posted points to Xamarin's explanation on Master-Detail page.
    Just to confirm are you creating a project from scratch or you just manually added the pages as described in the link?
    If possible, create a zip file of your application and upload it here.

  • NickprovsNickprovs ✭✭ USMember ✭✭
    > @MdNaushad said:
    > The link that you have posted points to Xamarin's explanation on Master-Detail page.
    > Just to confirm are you creating a project from scratch or you just manually added the pages as described in the link?
    > If possible, create a zip file of your application and upload it here.

    That page I linked to contains the code for the sample master detail application I described. It's in the top right. I'm asking where they defined their colors. I'm using styles.xml for my android project... but they are not. I'm asking how they did it. Again, the sample code is available for download on that page i linked.
Sign In or Register to comment.