从Xamarin表单中的条目控件中删除下划线

从Xamarin表单中的条目控件中删除下划线,xamarin,xamarin.forms,Xamarin,Xamarin.forms,我不熟悉Xamarin表单,不熟悉开发登录表单和使用材料设计(IVisual)。我已经创建了一个自定义条目类,并使用MaterialEntryRenderer继承该类以对其进行自定义。 我想实现的是删除下划线条目have。我看到了很多示例,但它们都使用EntryRenderer public class CustomEntryRenderer : MaterialEntryRenderer { public CustomEntryRenderer(Context context) : b

我不熟悉Xamarin表单,不熟悉开发登录表单和使用材料设计(
IVisual
)。我已经创建了一个自定义条目类,并使用
MaterialEntryRenderer
继承该类以对其进行自定义。 我想实现的是删除下划线
条目
have。我看到了很多示例,但它们都使用
EntryRenderer

public class CustomEntryRenderer : MaterialEntryRenderer
{
    public CustomEntryRenderer(Context context) : base(context) { }

    protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
    {
        base.OnElementChanged(e);

        if (Control != null)
        {
           Control.Background = null;
           Control.SetBackgroundColor(Android.Graphics.Color.Transparent);
        }
    }
}
公共类CustomEntryRenderer:MaterialEntryRenderer
{
公共CustomEntryRenderer(上下文):基本(上下文){}
受保护的覆盖无效OnElementChanged(ElementChangedEventArgs e)
{
基础。一个要素发生变化(e);
if(控件!=null)
{
Control.Background=null;
SetBackgroundColor(Android.Graphics.Color.Transparent);
}
}
}

它适用于
EntryRenderer
,但不适用于
MaterialEntryRenderer

尝试更改文本颜色属性

根据来源,它将改变您想要的:

_textInputLayout.BoxBackgroundColor = MaterialColors.CreateEntryFilledInputBackgroundColor(Element.BackgroundColor, Element.TextColor);

看:

试试这个,它对我有用

Control.EditText.Background = null;
Control.EditText.SetBackgroundColor(Android.Graphics.Color.Transparent);

创建一个效果并将其应用于控件,我刚刚在这里写了一篇详细的文章,介绍了如何通过简单的步骤来实现这一点:

您可以使用,请阅读为什么在自定义渲染器上使用效果?也许你可以把文章的某个部分复制粘贴到你的答案中,让你的答案不必跟随链接就可以清晰地表达出来。