Forum Xamarin.Forms

How to center my grid view inside my stack layout?

wlchoy96wlchoy96 Member ✭✭✭
edited September 2019 in Xamarin.Forms

I am using a sk canvas view in a grid view. I want my bitmap which is on the sk canvas view to be located in the center of my view and follow the size of different screen but I fail to do so. Any help? Below is my XAML code.

<StackLayout Grid.Row="1" HeightRequest="526" >
<StackLayout Padding="24,0,24,40" >
<Frame HeightRequest="526" WidthRequest="327" BorderColor="Black" Padding="0,0,0,0">
<StackLayout>
<Grid x:Name="grid" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.Effects>
<tt:TouchEffect Capture="True" TouchAction="OnTouchEffectAction"/>
</Grid.Effects>
<views:SKCanvasView x:Name="canvasView" Grid.Row="0" PaintSurface="OnCanvasViewPaintSurface"/>
</Grid>
</StackLayout>
</Frame>
</StackLayout>
</StackLayout>

Answers

  • wlchoy96wlchoy96 Member ✭✭✭

    Here are my coding

  • ColeXColeX Member, Xamarin Team Xamurai
    edited September 2019

    How to center my grid view inside my stack layout?

    I see three stackLayout in your code , which one ?

    I want my bitmap which is on the sk canvas view to be located in the center of my view and follow the size of different screen

    This is unclear, could you provide a screen shot to elaborate what you want ?

  • wlchoy96wlchoy96 Member ✭✭✭

    @ColeX it is in the third layout

  • wlchoy96wlchoy96 Member ✭✭✭

    It is something like this

  • ColeXColeX Member, Xamarin Team Xamurai

    Try

     <views:SKCanvasView x:Name="canvasView" Grid.Row="0" PaintSurface="OnCanvasViewPaintSurface" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand"/>
    
  • wlchoy96wlchoy96 Member ✭✭✭

    still cant

  • DirkWilhelmDirkWilhelm USMember ✭✭✭✭✭

    So you want to center your little image of the world in your canvas?

Sign In or Register to comment.