How to use a Merged Resource Dictionary with android XML? RRS feed

  • Question

  • User366385 posted

    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>

    Wednesday, March 27, 2019 2:36 PM

All replies

  • User371688 posted

    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.

    Friday, March 29, 2019 7:26 AM
  • User366385 posted

    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.

    Friday, March 29, 2019 9:24 AM