Xamarin 窗体圆形按钮

丹威尔曼

我正在使用 Xamarin Forms 4.1.0.581479 和相同版本的 Xamarin Forms Visual Material。

我制作了一个圆形按钮,用作几个模态叠加的关闭按钮。它看起来像这样:

在此处输入图片说明

问题是我无法使中间的 x(来自 Material 图标字体)变大。目前它的字体大小为 20

一旦我开始增加字体大小,例如增加到 30,这就会开始发生:

在此处输入图片说明

我试过将按钮的 Padding 设置为零,我试过使用 Horizo​​ntalOption,我试过将 BorderWidth 设置为 0,但似乎没有任何区别。

如何在不剪裁图标的情况下增加字体大小?

根据要求,这是我的 XAML:

<Button Grid.Column="1" Text="{x:Static constants:IconFont.Close}" Clicked="OnClicked" Style="{StaticResource CloseButton}" />

CloseButton风格如下:

    <Style x:Key="CloseButton" TargetType="Button">
      <Setter Property="FontFamily" Value="{StaticResource MaterialFontFamily}" />
      <Setter Property="BackgroundColor" Value="#0075BE" />
      <Setter Property="FontSize" Value="20" />
      <Setter Property="WidthRequest" Value="50" />
      <Setter Property="HeightRequest" Value="50" />
      <Setter Property="HorizontalOptions" Value="End" />
      <Setter Property="BorderRadius" Value="25" />
    </Style>
图斯阿拉尔

我认为你应该使用 ImageButton 而不是 Button:

<ImageButton VerticalOptions="Center" HorizontalOptions="Center" BackgroundColor="AliceBlue" CornerRadius="25" WidthRequest="50" HeightRequest="50">
                <ImageButton.Source>
                    <FontImageSource
                FontFamily="{DynamicResource MaterialFontFamily}"
                Glyph="{DynamicResource IconClose}"
                Size="30"
                Color="Red" />
                </ImageButton.Source>
</ImageButton>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章