Make a wave red underline for some words in edittext

I am creating a code editor and I am trying to dynamically add a red wavy underline if the user makes a mistake in the code that he writes. I tried using underlineSpan , but I don't see how to make it wavy. Changing color with .setColor () doesn't work either. Is there a Span that can help me, or is there a way to achieve this with Paint ?

+4
source share
1 answer

You can use TextPaint .

TextPaint tp = new TextPaint(); tp.linkColor = Color.BLACK; //you can use your color using Color.parseColor("#123456"); UnderlineSpan us = new UnderlineSpan(); us.updateDrawState(tp); SpannableString sp = new SpannableString("Welcome to android"); sp.setSpan(us, 11, 18, 0); // UnderlineSpan Object, Start position, End position, Flag. et.setText(sp); 

This works for me. Hope this helps you.

0
source

Source: https://habr.com/ru/post/1483082/


All Articles