Xaml 在xamarin形式中,图像的一半位于其他图像之上

Xaml 在xamarin形式中,图像的一半位于其他图像之上,xaml,layout,xamarin.forms,Xaml,Layout,Xamarin.forms,我正在使用xamarin表单 我需要创建一个布局,其中两个对象的位置如下: 另一个对象(正方形)上方一个(圆)的一半 我已经搜索过了,似乎我需要使用相对布局。。。 我尝试将两个对象设置在同一个网格(行和行0)中,然后使用constraintX将第二个对象设置在同一个Y轴上,并使用因子0和一个负常量…但没有成功。a删除了这些行并且不能在这里显示,不幸的是…唯一发生的事情是:两者在y中处于相同的位置,但我可以像上面的图片一样。。。 有人能帮我举个例子、想法或其他什么吗?多谢各位 我的代码现在-ro

我正在使用xamarin表单 我需要创建一个布局,其中两个对象的位置如下:

另一个对象(正方形)上方一个(圆)的一半

我已经搜索过了,似乎我需要使用相对布局。。。 我尝试将两个对象设置在同一个网格(行和行0)中,然后使用constraintX将第二个对象设置在同一个Y轴上,并使用因子0和一个负常量…但没有成功。a删除了这些行并且不能在这里显示,不幸的是…唯一发生的事情是:两者在y中处于相同的位置,但我可以像上面的图片一样。。。 有人能帮我举个例子、想法或其他什么吗?多谢各位

我的代码现在-rodape图像是正方形,重新加载是圆形 我现在认为重新加载在正方形下的事实是错误的,但是,现在,它是假装视觉…它给了我一个接近我想要的结果…但不完全正确

<!--Rodapé Grid-->
<RelativeLayout HorizontalOptions="FillAndExpand" 
                VerticalOptions="EndAndExpand" 
                BackgroundColor="Black">
    <Grid BackgroundColor="Red"
           RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,
                                                                 Property=Width,
                                                                 Factor=1,
                                                                 Constant=0}">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Image Source="rodape.png" 
               Aspect="Fill"
               HorizontalOptions="FillAndExpand"
               Grid.Row="0"
               Grid.Column="0">
            <Image.GestureRecognizers>
                <TapGestureRecognizer Tapped="FranqueadoOnTapGestureRecognizerTapped"/>
            </Image.GestureRecognizers>
        </Image>
        <!--Escrito Rodapé-->
        <StackLayout Orientation="Vertical"
                     VerticalOptions="End"
                     HorizontalOptions="FillAndExpand"
                     Grid.Row="0"
                     Spacing="0"
                     Grid.Column="0">
            <Image Source="reloadicon.png"/>
            <StackLayout Orientation="Horizontal" 
                         HorizontalOptions="Center">
                <local:MyLabel NamedFontSize="Medium" 
                               FontSizeFactor="0.7" 
                               Text="Seja um Franqueado:"
                               TextColor="White"
                               FontAttributes="Bold"
                               Style="{StaticResource labelsfont}"/>
                <local:MyLabel NamedFontSize="Medium" 
                               FontSizeFactor="0.7" Text="montanaexpress.com"
                               Style="{StaticResource labelsfont}"
                               TextColor="{StaticResource laranjacolor}"/>              
            </StackLayout>
        </StackLayout>
    </Grid>
</RelativeLayout>

试试这样,我觉得更简单:

<Grid>
    <BoxView Grid.Column="0" Grid.Row="1"
             Color="Red"
             HeightRequest="20"
             HorizontalOptions="FillAndExpand"/>
    <Frame Grid.Column="0" Grid.Row="0" Grid.RowSpan="2"
           BackgroundColor="Yellow"
           HorizontalOptions="CenterAndExpand"
           VerticalOptions="CenterAndExpand"
           WidthRequest="40"
           HeightRequest="40"
           CornerRadius="40"
           Margin="0,5,0,10"/>
</Grid>

您将得到:

编辑:

正如您在评论中所要求的,使用您的图像,您应该执行以下操作:

<Grid>   
    <Image Grid.Row="1" Grid.Column="0"
           Source="rodape.png" 
           Aspect="Fill"
           HorizontalOptions="FillAndExpand">
        <Image.GestureRecognizers>
            <TapGestureRecognizer Tapped="FranqueadoOnTapGestureRecognizerTapped"/>
        </Image.GestureRecognizers>
    </Image>               
    <Image Grid.Column="0" Grid.Row="0" Grid.RowSpan="2"
           Source="reloadicon.png"
           HorizontalOptions="CenterAndExpand"
           VerticalOptions="Center"/>
</Grid>


注意:我无法确定标签和图像应如何显示在布局中。您必须手动添加它

但是,当我使用“高度和宽度请求”时,我为视图设置了一个静态大小,不是吗?是的,我使用它来实现您的视觉模型。必须将BoxView和Frame元素更改为图像。忽略固定大小,并使用位置属性,如水平和垂直选项、栅格、列、行和行跨度。告诉我它是否可以像您希望的那样处理您的图像不是100%确定这里要问的是什么,但是如果您需要在正方形上绘制一个圆,这对于直接绘制到本地画布的自定义控件来说是一个不错的选择