本文介绍了Xamarin Forms:如何为按钮添加填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下XAML Xamarin.Forms.Button

I have the following XAML Xamarin.Forms.Button

<Button Text="Cancel" BackgroundColor="#3079a8" TextColor="White" />

我试图通过Padding属性向其中添加填充,但这没有用.在检查了论坛和文档之后,我意识到Xamarin.Forms.Button ,是否还有其他快速修复方法可以为按钮添加一些填充?一个代码示例将不胜感激.

I tried to add padding to it via the Padding property but that didn't work. After checking the forums and the docs, I realised there is no padding property in the documentation for Xamarin.Forms.Button (link to the docs), is there some other type of quick fix to add just a little bit more padding to a button? A code example would be greatly appreciated.

推荐答案

更新:

已将填充添加到 Xamarin.Forms v3.2 +

Padding has been added to the XF Button control in Xamarin.Forms v3.2+

<Button Padding="10,20,10,20" />

:

最好的方法是增加按钮的大小.

The best way to do it would be to increase the size of the button.

然后按照您认为合适的方式对齐文本.不幸的是,这是您可以做的最好的事情.如果您的文本中心对齐,则效果很好.如果它的左侧或右侧对齐,则不会太多.

Then align the text as you see fit. Unfortunately it is about the best you can do. It works well if you have your text center aligned. Not so much if its left or right aligned.

这篇关于Xamarin Forms:如何为按钮添加填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

查看更多