Toyin Sonoiki
Toyin Sonoiki

Reputation: 49

How do you remove the underline of a text in Xamarin Editor Control on the Android Platform?

Based on the research that I've done, the suggestion was to create a renderer in Android and set the background to transparent but it did not work. Here's the code.

    public class CustomEditorRenderer : EditorRenderer
    {
      protected override void OnElementChanged (ElementChangedEventArgs<Xamarin.Forms.Editor> e)
      {
        base.OnElementChanged(e);

        if (Control == null)

            return;

        Control.Background = new ColorDrawable(ClaimAllGraphics.Color.Transparent);
      }
   }

How do I remove the bottom line in an editor? Secondly, how do I ensure I still have the enter / return keypad on the keyboard? This is important as I have a multiline editor, so users should be able to press the enter / return keypad and move to the next line.

Upvotes: 1

Views: 1180

Answers (1)

York Shen
York Shen

Reputation: 9084

Remove the underline of a text in Xamarin Editor Control on the Android Platform?

Change ClaimAllGraphics.Color.Transparent to null:

public class CustomEditorRenderer : EditorRenderer
{
    public CustomEditorRenderer(Context context) : base(context)
    {
    }

    protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Editor> e)
    {
        base.OnElementChanged(e);

        if (Control == null)

            return;

        Control.Background = null;
        //Or Control.Background = new ColorDrawable(Android.Graphics.Color.Transparent);

    }
}

Effect.

Upvotes: 1

Related Questions