在Android中使用上划线

时间:2017-03-10 13:01:28

标签: java android html

我试图在TextView中显示重复的小数,但在Html.fromHtml中使用HTML标记不起作用。有没有其他方法可以在数字上显示线条?

1 个答案:

答案 0 :(得分:0)

结帐:

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

来源:Is there an easy way to strike through text in an app widget?