用指针建立框架

时间:2019-12-06 10:29:45

标签: xaml xamarin.forms

我想用指针建立一个像下面这样的框架,在这种情况下,是右边的三角形:

enter image description here

这怎么办?

1 个答案:

答案 0 :(得分:1)

使用BoxView创建两个堆叠的Grid,然后将顶部的旋转45度:

<StackLayout>
    <Grid HorizontalOptions="Center" VerticalOptions="CenterAndExpand" WidthRequest="100" HeightRequest="100">
        <BoxView HorizontalOptions="Center" VerticalOptions="CenterAndExpand" WidthRequest="100" HeightRequest="80" BackgroundColor="Red"/>
        <BoxView HorizontalOptions="End" VerticalOptions="CenterAndExpand" 
                 WidthRequest="50" HeightRequest="50" BackgroundColor="Red" Rotation="45"/>
        <StackLayout VerticalOptions="Center" HorizontalOptions="Center" Spacing="0">
            <Label HorizontalTextAlignment="Center" CharacterSpacing="2" FontSize="13" TextColor="White" Text="DECEMBER"/>
            <Label HorizontalTextAlignment="Center" FontAttributes="Bold" FontSize="22" TextColor="White" Text="25"/>
            <Label HorizontalTextAlignment="Center" CharacterSpacing="2" FontSize="13" TextColor="White" Text="WEDNESDAY"/>
        </StackLayout> 
    </Grid>
</StackLayout>

enter image description here