Textview with scratched letter

2

How can I get this result ̶W̶a̶l̶l̶a̶c̶e̶ ̶R̶o̶b̶e̶r̶t̶o̶c̶ equal in the name of the first list below ... the list is scratched because I did it on the server side .. the intention and leave the result of the table of the middle scratched since it is not part of the calculation anyway ... thank you right away.

    
asked by anonymous 18.10.2017 / 21:50

2 answers

3

You should 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 scratched.

    
18.10.2017 / 22:00
0

Another solution that works on Views that do not have PaintFlags:

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