从 Xamarin 表单中的条目控件中删除下划线 [英] Remove underline from Entry Control in Xamarin Forms

查看:44
本文介绍了从 Xamarin 表单中的条目控件中删除下划线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Xamarin-Forms 的新手,我正在开发登录表单并使用 Material Design (IVisual).我创建了一个自定义 Entry 类并使用 MaterialEntryRenderer 继承它来自定义它.我想要实现的是删除下划线 Entry 有.我看过很多例子,但他们都使用 EntryRenderer 代替.

I am new to Xamarin-Forms and developing a login form and using Material Design (IVisual). I have created a custom Entry class and inherited it with MaterialEntryRenderer to customize it. Thing i want to achieve is to remove underline Entry have. I have see alot of examples but all of them use EntryRenderer instead.

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);
        }
    }
}

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

it work fine with EntryRenderer but not for MaterialEntryRenderer.

推荐答案

试试这个,它对我有用

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

这篇关于从 Xamarin 表单中的条目控件中删除下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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