创建不同的颜色穿透 [英] create different color strike through

查看:13
本文介绍了创建不同的颜色穿透的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建文本视图,文本颜色为黑色,删除线为红色,我尝试使用 html 但似乎不起作用

I am trying to create textview with text color as black and strikthrough as red, I tried to use html but does not seems to work

String styledText = "<span style='color:red;text-decoration:line-through'><span style='color:black'>TEXT</span></span>";    
myText.setText(Html.fromHtml(styledText));

我也试过下面的方法,但不知道如何为删除线定义不同的颜色

I also tried below method but don't know how do define different color for strikethrough

myText.setPaintFlags(myText.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

推荐答案

如果你想删除 TextView 中的所有文本,你可以简单地创建一个 TextView<的子类/code>,您可以在其中使用您选择的颜色绘制划线.

If you want to strike through all the text in the TextView you can simply create a sub-class of TextView in which you draw the strike line with the color of your choice.

这篇关于创建不同的颜色穿透的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆