Xamarin形式的其他图像上方的一半图像 [英] Half of an image above other image in xamarin forms

查看:84
本文介绍了Xamarin形式的其他图像上方的一半图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am working with xamarin forms And I need to create a layout with two objects positionated like that:

一个圆的一半在另一个物体(正方形)上方

half of one(circle) above the other object(square)

我已经搜索过,看来我需要使用相对布局了... 我试图这样做,将两个对象都设置在同一网格中(行和行0),然后使用constraintX将第二个对象设置在同一个Y中,且因子0和负常数...但是它没有用.不幸的是,a删除了这些行并且无法在此处显示...发生的唯一事情是:两者在y中处于相同位置,但是我可以像上面的图像一样... 有人可以帮我一个例子,想法或其他吗?非常感谢你!

I have searched and it seem I need to use relative layout... I tried to do that setting the both objects in the same grid (row and line 0), and then, using constraintX to set the second in the same Y with factor 0 and a negative constant...But it didn't work. The a deleted the lines and can't show here, unfortunately...the only thing that happend in this is: the both was in the same position in y, but I could do like the image above... Can someone help me with an example, idea or anything? thank you very much!

现在我的代码-剑杆像是正方形,重载是圆圈 我现在的事实是重新加载在正方形下是错误的,但是,现在,它只是假装视觉效果……这给了我想要的接近结果……但不完全是

My code now - the rodape image is the square and the reload is the circle I now the fact that the reload is under the square is wrong, but, for now, it is pretend the visual...an it gives me a result close that I want...but not exactly

<!--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>

推荐答案

尝试类似的方法,我认为它更简单:

Try something like this, I think it's simpler:

<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>

您将获得:

根据您在评论中的要求,使用图片,您应该执行以下操作:

As you've required at comments, using your images you should do something like this:

<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>

注意:我无法弄清楚应如何在布局中显示标签和图像.您必须手动添加

这篇关于Xamarin形式的其他图像上方的一半图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆