I have a Xamarin.Forms v188.8.131.52 PCL XAML multi-project/platform solution on visual studio 2015/win10, which utilizes SkiaSharp v1.56.1. It seems like there is a contradiction about size info of the SKCanvasView, as I will try to describe below.
XAML structure is ContentPage \ ScrollView \ Grid \ SKCanvasView:
<views:SKCanvasView Grid.Row="8" Grid.Column="0" Grid.ColumnSpan="3" x:Name="canvasview" PaintSurface="OnPaintSchematic" HeightRequest="100" VerticalOptions="Start" HorizontalOptions="Fill" />
I have below code in OnPaintSchematic event handler (e is of type SKPaintSurfaceEventArgs):
canvas.DrawText("Info.ColorType=" + e.Info.ColorType.ToString(), 10, e.Info.Height - 70, paint); canvas.DrawText("Info.WidthxHeight=" + e.Info.Width.ToString() + "x" + e.Info.Height.ToString(), 10, e.Info.Height - 40, paint); canvas.DrawText("SKCanvasView.WidthxHeight=" + canvasview.Width.ToString() + "x" + canvasview.Height.ToString(), 10, e.Info.Height - 10, paint);
This code generates below output:
On UWP (win10 64-bit):
On Android hardware (HTC One, API 21):
On Android emulator (Galaxy Nexus, API 19):
It seems like, on different platforms, two property sets give different sizes. Setting SKCanvasView's HeightRequest at code, rather than or together with setting XAML property, doesn't make any difference. By visual inspection, I can say Info.WidthxHeight is the right one. But I cannot understand the mechanics behind SKCanvasView.WidthxHeight values, which is same or half or one-third of Info.WidthxHeight. Main problem is I cannot set SKCanvasView's real-drawn height (e.Info.Height) by setting HeightRequest property. Any explanation and correction is appreciated.