本文介绍了只有圆角底角?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使我的 Stacklayout 的背景变圆(仅右下侧和左下侧).我正在寻找如何搜索,但无法确定.我该怎么做?

I am trying to make my Stacklayout's background rounded (only right and left bottom sides). I looked for how to search but couldn't make sure. How can I do it?

推荐答案

您可以使用 Xamarin.Forms.PancakeView 包:

1- 在您的共享平台项目中安装它(最新版本需要 Xamarin.Forms 4.8.0.1451 及更高版本).

1- Install it in your shared as in your platform projects (latest version require Xamarin.Forms 4.8.0.1451 and upper).

2- 在您的 xaml 中包含该包的命名空间:

2- Include the namespace for that package in your xaml:

xmlns:pancake="clr-namespace:Xamarin.Forms.PancakeView;assembly=Xamarin.Forms.PancakeView"

3- 创建一个 PancakeView,它将在其中托管您的控件:

3- Create a PancakeView which will host your controls inside:

<pancake:PancakeView Padding="10"
                     BackgroundColor="Blue"
                     CornerRadius="0,0,40,40">
    <StackLayout Padding="0"
                 HorizontalOptions="FillAndExpand">

        <Label Text="hello World"
               FontSize="Medium"
               TextColor="White"
               HorizontalOptions="Center"/>

        <Button Text="More Details"/>
    </StackLayout>
</pancake:PancakeView>

您可以使用 CornerRadius 属性来调整它的形状.

you can play on it shape with the CornerRadius propety.

只是想展示 Gradients 的用法作为问题截图包括一张.

Just wanted to show the usage of Gradients as the question screenshots includes one.

有关此包的更多详细信息,您可以查阅他们的维基页面.

For more details on this package you can consult their Wiki page.

<StackLayout>
    <pancake:PancakeView Padding="10"
                         BackgroundGradientStartPoint="1,0"
                         BackgroundGradientEndPoint="1,1"
                         HeightRequest="300"
                         VerticalOptions="Start"
                         CornerRadius="0,0,40,40">

        <pancake:PancakeView.BackgroundGradientStops>
            <pancake:GradientStopCollection>
                <pancake:GradientStop Color="#44F3FF"
                                      Offset="0"/>
                <pancake:GradientStop Color="#46ACDC"
                                      Offset="0.4"/>
                <pancake:GradientStop Color="#0057CB"
                                      Offset="1"/>
            </pancake:GradientStopCollection>
        </pancake:PancakeView.BackgroundGradientStops>

        <StackLayout VerticalOptions="FillAndExpand">
            <Label Text="Hello World"
                   HorizontalOptions="Center"
                   FontSize="Large"
                   TextColor="Black"/>

            <Button Text="More Details"
                    BackgroundColor="#0057CB"
                    BorderWidth="2"
                    BorderColor="#44F3FF"
                    VerticalOptions="CenterAndExpand"
                    CornerRadius="25"/>
        </StackLayout>
    </pancake:PancakeView>

    <Label Text="What are you doing today?"
           FontSize="Title"
           Margin="30,0,0,0"
           TextColor="Black"/>
</StackLayout>

这篇关于只有圆角底角?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 13:30