Forum Xamarin Xamarin.Forms

How to use a Merged Resource Dictionary with android XML?

I'm using an xml file with android to define the style of a button. However when it comes to defining a color I'm not sure how I can access the merged dictionary from it. At the moment I'm using<solid android:color="@android:color/darker_gray"/> so how do I replace that with a reference to this... <Color x:Key="Gray">#777777</Color>


  • jezhjezh Member, Xamarin Team Xamurai

    You can get the color reference at first like this.

    public Color grayColor;
    grayColor = (Color)App.Current.Resources["backgroundColor"];

    but I recommend you define it directly in the Android resource, this way is easier.

  • DemonolithDemonolith Member ✭✭
    Do you mean define the color in a colours.xml file? Though then if I want to add or change things I need to do it twice but I suppose it would be the easiest way.
Sign In or Register to comment.