[mono-android] DrawLine problem with Paint.StrokeWidth = 1
Narcís Calvet
narcis at steema.com
Thu Mar 17 05:30:54 EDT 2011
Hi Jon,
-----Original Message-----
From: monodroid-bounces at lists.ximian.com
[mailto:monodroid-bounces at lists.ximian.com] On Behalf Of Jonathan Pryor
Sent: dimecres, 16 / març / 2011 16:49
To: monodroid at lists.ximian.com
Subject: Re: [mono-android] DrawLine problem with Paint.StrokeWidth = 1
>Could you provide a test case?
Yes, find it below. I just created a new MonoDroid application and added
code below. You'll see that only 2 red lines (StrokeWidth = 1) are painted
while all lime lines (StrokeWidth = 2) are painted.
>I don't know why this would fail, though I imagine that Mono isn't the
problem (porting the code to Java and seeing what Java does would narrow
this down).
A colleague did a similar test with Java for Android in Eclipse and worked
fine there.
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Graphics;
namespace MonoDroidApplication1
{
class MyControl : View
{
public MyControl(Context context)
: base(context) { }
protected override void OnDraw(Canvas canvas)
{
base.OnDraw(canvas);
Paint pen = new Paint();
pen.Color = Color.Red;
pen.StrokeWidth = 1;
pen.SetStyle(Paint.Style.Stroke);
canvas.DrawLine(100, 100, 200, 90, pen); //not painted
canvas.DrawLine(100, 100, 200, 100, pen);
canvas.DrawLine(100, 100, 200, 110, pen); //not painted
canvas.DrawLine(100, 100, 200, 120, pen); //not painted
canvas.DrawLine(100, 100, 200, 130, pen);
pen.Color = Color.Lime;
pen.StrokeWidth = 2;
canvas.DrawLine(100, 200, 200, 190, pen);
canvas.DrawLine(100, 200, 200, 200, pen);
canvas.DrawLine(100, 200, 200, 210, pen);
canvas.DrawLine(100, 200, 200, 220, pen);
canvas.DrawLine(100, 200, 200, 230, pen);
}
}
[Activity(Label = "My Activity", MainLauncher = true)]
public class Activity1 : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var ctrl = new MyControl(this);
SetContentView(ctrl);
}
}
}
Thanks in advance.
Best Regards,
Narcís Calvet
Steema Software
http://www.steema.com
http://twitter.com/SteemaSoftware
https://www.facebook.com/SteemaSoftware
More information about the Monodroid
mailing list