Forum Xamarin.Android

RectangleOptions Color

I want to use PolygonOptions class. I try to change the FillColor and StrokeColor.

Any object of PolygonOptions has a property that named FillColor and another named StrokeColor. but they are readonly. so I think we should use rectOptions .InvokeFillColor(int) and rectOptions.InvokeStrokeColor (int) but as you can see they accept integers. what is the integer parameters?

I do not want that the rectangle be fill and also want a red color for margins. what should I do?


  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai


    From what I can tell from Android's guide, the integer value should be the 32bit hex number for an ARGB color, usually best visualized in hex e.g. 0xff000000 for black. That's ff for the alpha and 00 for red, green, and blue. Blue would be 0xff0000ff, green 0xff00ff00, etc. First pair of hex digits is the alpha, second pair is the red, third pair green, and fourth pair blue. Once you make your color in hex, then convert to an int with:

    int strokeColor = Int32.Parse("ffff0000", System.Globalization.NumberStyles.HexNumber); // ffff0000 = Red

    You should then be able to pass this int in:
    PolygonOptions polygonOptions = new PolygonOptions();

    I hope this helps.

    All the best


  • JohnSRadJohnSRad FRMember ✭✭

    @Jgoldberger thanks. It helped me to much :)

Sign In or Register to comment.