Xamarin - C# 中 Java Android.graphics.Paint setColor(int color) 的等效项是什么?
What's the equivalent of Java Android.graphics.Paint setColor(int color) in Xamarin - C#?
示例代码:
using Android.Graphics;
int _color
Paint mPaint;
mPaint.Color = ? // Here I'm confused.
在Java中:
mPaint.setColor( _color );
Xamarin.Android会有什么?
如何通过 int 在 Paint 中设置颜色?
我做的参考:
- http://developer.android.com/reference/android/graphics/Paint.html#setColor(int)
- https://developer.xamarin.com/api/property/Android.Graphics.Paint.Color/
任何答案!
终于找到解决办法了
Methods which start with get
and set
may be mapped to properties:
http://developer.xamarin.com/guides/android/advanced_topics/api_design/#Properties
The Paint.setColor(int) method is bound as the Paint.Color property:
http://developer.xamarin.com/api/property/Android.Graphics.Paint.Color/
Instead of an int
value, it instead takes an Android.Graphics.Color
structure:
mPaint.Color = new Android.Graphics.Color (_color);
参考:Bug 37716
感谢@Jonathan_Pryor。
示例代码:
using Android.Graphics;
int _color
Paint mPaint;
mPaint.Color = ? // Here I'm confused.
在Java中:
mPaint.setColor( _color );
Xamarin.Android会有什么?
如何通过 int 在 Paint 中设置颜色?
我做的参考:
- http://developer.android.com/reference/android/graphics/Paint.html#setColor(int)
- https://developer.xamarin.com/api/property/Android.Graphics.Paint.Color/
任何答案!
终于找到解决办法了
Methods which start with
get
andset
may be mapped to properties:http://developer.xamarin.com/guides/android/advanced_topics/api_design/#Properties
The Paint.setColor(int) method is bound as the Paint.Color property:
http://developer.xamarin.com/api/property/Android.Graphics.Paint.Color/
Instead of an
int
value, it instead takes anAndroid.Graphics.Color
structure:mPaint.Color = new Android.Graphics.Color (_color);
参考:Bug 37716
感谢@Jonathan_Pryor。