gpt4 book ai didi

xaml - 如何将背景图像设置为形状

转载 作者:行者123 更新时间:2023-12-03 19:34:54 25 4
gpt4 key购买 nike

我是 Xamarin Forms 的新手,我来自 WPF 背景。在 WPF 中,很容易将背景图像(远程)设置为形状。 Xamarin Forms 中是否有任何等效的东西?

最佳答案

在将 Shapes 和 Paths 引入 Xamarin.Forms 之后,您可以在 Grid 中实现它:

<Grid HorizontalOptions="Center" VerticalOptions="Center">
<Ellipse Stroke="blue" StrokeThickness="5" Fill="Black" Aspect="Fill"/>
<Image Source="xamarin.png" WidthRequest="300" HeightRequest="300"/>
</Grid>
enter image description here

Frame 的圆角:
<Grid HorizontalOptions="Center" VerticalOptions="Center">
<Frame WidthRequest="200" CornerRadius="80"
BackgroundColor="Black" HeightRequest="200"/>
<Image Source="xamarin.png" WidthRequest="200" HeightRequest="200"/>
</Grid>
enter image description here

使用 Path :
<Grid HorizontalOptions="Center" VerticalOptions="Center">
<Path Stroke="blue"
Data="m123.87668,219.80811l21.30223,-42.92685l36.89384,-24.78565l42.60447,0l36.89384,24.78565l21.30223,42.92685l0,49.57131l-21.30223,42.92685l-36.89384,24.78564l-42.60447,0l-36.89384,-24.78564l-21.30223,-42.92685l0,-49.57131z"
StrokeThickness="5" WidthRequest="200" HeightRequest="200"
Aspect="Fill" Fill="Black"/>

<Image Source="xamarin.png" WidthRequest="200" HeightRequest="200"/>
</Grid>
enter image description here

相关文档
  • 微软博客:Drawing UI with Xamarin.Forms Shapes and Paths .
  • 微软官方文档:Xamarin.Forms Shapes .
  • GitHub:规范:Shapes & Paths
  • 关于xaml - 如何将背景图像设置为形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50958787/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com