Xamarin Forms:如何向按钮添加填充? [英] Xamarin Forms: How can I add padding to a button?

查看:23
本文介绍了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.

推荐答案

更新:

填充已添加到 XF 按钮控件

<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:如何向按钮添加填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆