【发布时间】:2021-10-13 11:15:49
【问题描述】:
我想制作一个按钮,带有文本的图像按钮 svg。
在 xaml 中:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
mc:Ignorable="d"
x:Class="loginUI.L202">
<StackLayout VerticalOptions="Center" Spacing="50">
<StackLayout.Resources>
<ResourceDictionary>
<Style TargetType="Button">
<Setter Property="HorizontalOptions" Value="FillAndExpand"/>
</Style>
<Style TargetType="Image">
<Setter Property="WidthRequest" Value="50"/>
</Style>
</ResourceDictionary>
</StackLayout.Resources>
<Button Text=" test" BackgroundColor="Wheat" BorderRadius="20" TextColor="red">
<Button.Image>
<OnPlatform x:TypeArguments="FileImageSource" Android="home.svg" iOS="home.svg"/>
</Button.Image>
</Button>
</StackLayout>
如何设置home.svg的尺寸(WidthRequest | HeightRequest)? TargetType="Image" 不起作用。
或者
有一种方法可以插入到按钮中,例如?
<Button> <Path Data="M185.255 512c-76.201 ....." /> </Button>
【问题讨论】:
标签: xaml xamarin svg button xamarin.forms