我正在做我认为使用跨平台相当简单的事情。 我创建了一些按钮并将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.
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 }更多推荐
按钮,I'm,button,没有,电脑培训,计算机培训,IT培训"/> <meta name="descrip
发布评论