Xamrin-我的android按钮看起来糟透了 [英] Xamrin - My android buttons look awful

查看:64
本文介绍了Xamrin-我的android按钮看起来糟透了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做使用跨平台的相当简单的事情. 我创建了一些按钮,并将Image属性设置为使用我的同事创建的一些按钮图像.在iOS中,它们看起来像预期的那样:

I'm doing what I thought would be fairly simple using cross platform. I created some buttons and set the Image property to use some button images my co-worker created. In iOS, they look as expected:

但是,在Android中,每个按钮周围都有各种阴影边框,它们似乎设置为我没有明确设置的矩形大小:

However in Android, there's a shadow border of sorts around every button and they seem to be set to some rectangular size that I'm not explicitly setting:

我已经尝试了很多我可以在xamarin按钮类上找到的属性,但我没有运气. BorderWidth,BorderColor和BorderRadius似乎没有任何作用.谁能告诉我如何消除所有灰色边框并适当调整它们的大小?

I've tried pretty much every property I could find on the xamarin button class and I'm having no luck. BorderWidth, BorderColor and BorderRadius don't appear to do anything. Can anyone tell me how to get rid of all the grey borders and size them properly?

谢谢.

推荐答案

您看到的是按钮本身,而不是按钮 border .

What you are seeing it the button itself, not the button border.

您可以将按钮颜色设置为透明,但是您将具有按钮边框,并且宽度不会受到影响,因为默认情况下它将根据其所在的布局容器自动展开.

You could set the button color to transparent, but you will have a button border, and the width is unaffected as by default it will auto-expand based upon the layout container that it is within.

要覆盖该行为,一种选择是设置其HorizontalOptionsLayoutOptions,或者您可以将按钮嵌入到网格中,等等.

To override that behavoir, one option is to set the LayoutOptions of its HorizontalOptions, or you could embed the buttons into a grid, etc...

如果Xamarin图标的宽度为72像素:

In the case of Xamarin icon which is 72 pixel wide:

new Button {
    Image = "icon.png",
    WidthRequest = 72,
    HeightRequest = 72,
    BackgroundColor  = Color.Transparent,
    HorizontalOptions = LayoutOptions.Start
}

这篇关于Xamrin-我的android按钮看起来糟透了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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