【发布时间】:2019-12-20 02:05:04
【问题描述】:
【问题讨论】:
标签: xamarin xamarin.ios xamarin.android xamarin.forms
【问题讨论】:
标签: xamarin xamarin.ios xamarin.android xamarin.forms
我不确定这种方法是否有问题,因为它看起来很简单但没有人建议。
但我不明白为什么不能只使用 Frame 并将 IsClippedToBounds 设置为 true。这为您提供了一个内置的圆角半径,然后您可以根据需要进行调整。
<Grid>
<Frame
Padding = "0"
CornerRadius ="20"
IsClippedToBounds="true">
<Editor [...whatever...]/>
</Frame>
</Grid>
我目前正在使用这个解决方案,它对我有用。
【讨论】:
我有完全相同的要求,并决定创建名为EntryEx 的自定义控件。可以找到源代码HERE。
这是此控件支持的功能列表。
我已经为 iOS 和 Android 创建了自定义渲染器来支持这些属性。 要使用该控件,只需执行以下操作。
EntryEx 添加到您的表单项目中。EntryExRenderer-s。就是这样。享受吧。
【讨论】:
kyurkchyan 的解决方案是 bang on,只需将 Android entryRendere 中的 UpdateBackground 方法更改为:
private void UpdateBackground(XEntry xEntry)
{
if (_renderer != null)
{
_renderer.Dispose();
_renderer = null;
}
var oldBg = xEntry.BackgroundColor;
xEntry.BackgroundColor = Xamarin.Forms.Color.Transparent;
_renderer = new BorderRenderer();
Control.SetBackground(_renderer.GetBorderBackground(xEntry.BorderColor, oldBg, xEntry.BorderWidth, xEntry.BorderRadius));
}
它也可以在 Android 上运行!
【讨论】: