Textview with scratched letter

Asked

Viewed 1,710 times

2

how can I get this result ̶W̶a̶l̶l̶a̶c̶e̶ ̶R̶o̶b̶e̶r̶t̶o̶c̶ like this in the name of the first list below... the one on the list is crossed out because I did it on the server side.. the intention and leave the result of the middle table crossed since it is not part of the calculation finally....

inserir a descrição da imagem aqui

2 answers

4


You must use the code below:

TextView tv = (TextView) findViewById(android.R.id.text1);
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

That way your text will be crossed out.

0

Another solution that works on Views that don’t have Paintflags:

tv.setText(s, TextView.BufferType.SPANNABLE);
Spannable spannable = (Spannable) tv.getText();
spannable.setSpan(new StrikethroughSpan(), 0, s.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.