通过创建不同的颜色罢工 [英] create different color strike through

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

问题描述

我想创建TextView的文本颜色为黑色,strikthrough为红色,我试图用HTML,但似乎并不工作。

 字符串的StyledText =<跨度风格=颜色:红色;文字修饰:行通'><跨度风格=颜色:黑'>文字< /跨度>&所述; /跨度>中;
myText.setText(Html.fromHtml(的StyledText));
 

我也尝试下面​​的方法,但不知道该怎么办定义不同的颜色删除线

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

解决方案

如果你想删除线中的所有文本的的TextView 您可以简单地创建一个子类对的TextView 在其中绘制罢工符合你选择的颜色。

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);

解决方案

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天全站免登陆