Bug 374 - Android.Graphics.Paint.Color property should be of type Android.Graphics.Color
Summary: Android.Graphics.Paint.Color property should be of type Android.Graphics.Color
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 1.0
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2011-08-23 22:54 UTC by Jonathan Pryor
Modified: 2014-03-28 13:41 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jonathan Pryor 2011-08-23 22:54:45 UTC
The Android.Grahpics.Paint.Color property is an `int`. It should be a Android.Graphics.Color, so that you can do sane things like:

    Paint p = GetSomePaint();
    p.Color = Color.Black;

instead of:

    p.Color = Color.Black.ToArgb ();

See also: http://docs.mono-android.net/index.aspx?link=P%3aAndroid.Graphics.Paint.Color
Comment 1 Jonathan Pryor 2012-04-18 15:48:00 UTC
Fixed in commit 60346ad8, and should be part of the final 4.2.0 release.

This changes the public members:

      Android.Content.Res.TypedArray.GetColor(int, int)
I don't see any other 'getColor' or 'setColor' methods within API 15.
This doesn't change any method overloads, though a quick look at the API 15 XML description suggests that there are 32 methods that take a `int color` parameter that should either be replaced with a Color variant over overloaded with a Color version.
Comment 2 Jonathan Pryor 2012-04-20 12:09:04 UTC
Constructor and method parameters which represent "Color" parameters are fixed in commit 1f2b952e. A parameter is considered to be a "color" parameter if it's of type `int` and it has one of the following names:


For example, this changes the `ColorDrawable(int)` constructor to `ColorDrawable(Color)`, which is much saner.
Comment 3 Ben Dodson 2013-06-05 21:11:05 UTC
Is this really the right thing to do on a Paint? Often Paint color properties are set inside of a call to onDraw, and allocating a new Color object seems unnecessarily costly.
Comment 4 Jonathan Pryor 2013-06-05 21:17:27 UTC
Android.Graphics.Color is a struct. Allocations are cheap, and have no GREF or GC implications (unless boxed, and there's still no GREF implications).


(This is one of the rare deviations from the Java API that we expose; Android/Java uses `int` for Color instances, and we replaced most of the `int`s with the `Android.Graphics.Color` struct.)
Comment 5 Ben Dodson 2013-06-05 21:18:46 UTC
Great, thanks for the clarification.
Comment 6 Udham Singh 2014-03-28 13:41:26 UTC
I have checked this issue on following builds:

Mac OS X 10.9.2
Xamarin Studio : 4.2.3 (build 60)
Xamarin.Android : 4.13.0 (Enterprise Edition)

Screencast: http://screencast.com/t/YkqfGconGf

This issue is working fine. Hence, I am closing this issue.