首页 > 解决方案 > 在xamarin android中给出长值时未绘制canvas.DrawPath

问题描述

我在 Xamarin android 中工作。

示例代码:

Path.MoveTo(22020100.00,22020100.00)

我试图从这个位置画线,但在提供 long 值时没有画线。

标签: androidxamarin.androidandroid-canvas

解决方案


画线有两种方法:

第一种方法:

canvas.DrawLine(startX, startY, stopX, stopY, paint);

第二种方法:

Paint paint = new Paint();
paint.SetStyle(Paint.Style.Stroke);  // When drawing a line using a path, specify that the Paint Style is STROKE. Otherwise Paint will use the default style-fill. This Style does not create a line using a path
paint.Color = Color.Red;
Path path = new Path();
path.MoveTo(22020100.00f, 22020100.00f);
path.LineTo(120, 250);
canvas.DrawPath(path, paint);

推荐阅读