如何将 SKCanvasView 与同一页面中的其他视图组合?

How to combine SKCanvasView with other views in the same page?

我正在尝试在 AndroidXamarin Form 项目的同一页面上显示 SKCanvasViewListViewLabel 等其他视图.

我的Xaml代码:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:skia="clr-namespace:SkiaSharp.Views.Forms;assembly=SkiaSharp.Views.Forms"
             x:Class="AndroidExample.Principal"
             Title="myApp">

  <StackLayout Orientation="Vertical">
      <skia:SKCanvasView x:Name="canvas" PaintSurface="Canvas_Paint_Surface"/>
      <Label Text="EXAMPLE" FontSize="Large" FontAttributes="Bold"/>
  </StackLayout>

</ContentPage>

部署应用程序时没有显示任何内容。 LabelSKCanvasView被隐藏或类似的东西。

我也尝试过不使用 StackLayout,结果相同 :(

改用网格

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:skia="clr-namespace:SkiaSharp.Views.Forms;assembly=SkiaSharp.Views.Forms"
                 x:Class="AndroidExample.Principal"
                 Title="myApp">

      <Grid>
          <skia:SKCanvasView x:Name="canvas" PaintSurface="Canvas_Paint_Surface"/>
          <Label Text="EXAMPLE" FontSize="Large" FontAttributes="Bold"/>   
     </Grid>

</ContentPage>

有了这个,你的 SKCanvasView 将填充整个视图,你可以在上面放置任何控件。 StackLayout 堆叠项目。使用您当前的代码, SKCanvasView 的 Height =0;