首页 > 解决方案 > Remove underline from Entry Control in Xamarin Forms

问题描述

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

it work fine with EntryRenderer but not for MaterialEntryRenderer.

标签: xamarinxamarin.forms

解决方案


试试这个,它对我有用

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

推荐阅读