Xamrin

编程入门 行业动态 更新时间:2024-10-25 00:31:42
Xamrin - 我的android按钮看起来很糟糕(Xamrin - My android buttons look awful)

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

然而在Android中,每个按钮周围都有一个阴影边框,它们似乎设置为一些我没有明确设置的矩形尺寸:

我已经尝试了几乎我在xamarin按钮类上找到的所有属性,但我没有运气。 BorderWidth,BorderColor和BorderRadius似乎没有做任何事情。 任何人都可以告诉我如何摆脱所有灰色边框并正确调整它们的大小?

提前致谢。

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:

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:

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?

Thanks in advance.

最满意答案

你看到的是按钮本身,而不是按钮边框

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

在此处输入图像描述

要覆盖该行为,一个选项是设置其HorizontalOptions的LayoutOptions ,或者您可以将按钮嵌入网格等...

对于Xamarin图标,其宽度为72像素:

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

在此处输入图像描述

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.

enter image description here

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

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 }

enter image description here

更多推荐

按钮,I'm,button,没有,电脑培训,计算机培训,IT培训"/> <meta name="descrip

本文发布于:2023-07-31 21:02:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1347382.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Xamrin

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!