[mono-android] DrawLine problem with Paint.StrokeWidth = 1

Narcís Calvet narcis at steema.com
Mon Mar 21 12:43:39 EDT 2011


Hello Jon,

-----Original Message-----
From: monodroid-bounces at lists.ximian.com
[mailto:monodroid-bounces at lists.ximian.com] On Behalf Of Narcís Calvet
Sent: dilluns, 21 / març / 2011 16:48
To: monodroid at lists.ximian.com
Subject: Re: [mono-android] DrawLine problem with Paint.StrokeWidth = 1

>Wow! I still see some inconsistencies with text rendering too. I'll try to
find a test case I can post here.

Finally came up with the code example below which reproduces the text
problem with minSdkVersion attribute. At
http://www.steema.us/files/public/support/TextIssue.zip you can download the
two screenshots I took. One has the minSdkVersion attribute and the other
not. Initializing the Paint object using the antialias flag doesn't help
either. Do you have any idea on what may be going on here?

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);

      Display disp = GetDisplay();

      Paint p = new Paint();
      p.Color = Color.Lime;

      int count = 0;

      for (int y = 0; y < disp.Height; y=y+10)
      {
        Random rand = new Random();
        canvas.DrawText(count.ToString() + " - " + rand.Next().ToString(),
100, y, p);
        count++;
      }
    }

    private Display GetDisplay()
    {
      return
this.Context.GetSystemService(Android.Content.Context.WindowService).JavaCas
t<Android.Views.IWindowManager>().DefaultDisplay;
    }
  }

  [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