我想在全屏上的SKCanvasView上方放置一个按钮

问题描述 投票:0回答:1

图像通过SKCanvasView显示(全屏)。我想在其中放置按钮之类的控件,但它在启动时显示,但是在显示图像时消失。!

enter image description here

c# xamarin xamarin.android maps skiasharp
1个回答
0
投票

您可以使用absolute-layout布置控件:

public TileAlignmentPage()
{
    Title = "Tile Alignment";
    var layout = new AbsoluteLayout();

    SKCanvasView canvasView = new SKCanvasView();
    canvasView.PaintSurface += OnCanvasViewPaintSurface;
    ...
    AbsoluteLayout.SetLayoutBounds(canvasView, new Rectangle(0, 0, 1, 1));
    AbsoluteLayout.SetLayoutFlags(canvasView, AbsoluteLayoutFlags.All);

    Button clear_button = new Button { Text = "-" };
    ...
    AbsoluteLayout.SetLayoutBounds(clear_button, new Rectangle(0.5, 0.45, 250, 50));
    AbsoluteLayout.SetLayoutFlags(clear_button, AbsoluteLayoutFlags.PositionProportional);

    Button update_button = new Button { Text = "+" };
    ...
    AbsoluteLayout.SetLayoutBounds(update_button, new Rectangle(0.5, 0.55, 250, 50));
    AbsoluteLayout.SetLayoutFlags(update_button, AbsoluteLayoutFlags.PositionProportional);

    layout.Children.Add(canvasView);
    layout.Children.Add(clear_button);
    layout.Children.Add(update_button);
    Content = layout;
}
© www.soinside.com 2019 - 2024. All rights reserved.