如何强调文本的TextView与一些不同的颜色比文本? [英] How to underline text in TextView with some different color than that of text?
本文介绍了如何强调文本的TextView与一些不同的颜色比文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道如何在一个TextView下划线的文本。但如何强调一些不同颜色的文字?
下划线可以做到:
TextView的T =(的TextView)findViewById(R.id.textview);
t.setPaintFlags(t.getPaintFlags()| Paint.UNDERLINE_TEXT_FLAG);
t.setText(下划线文字);
让说我的文字颜色是黑色的,我想强调,蓝色一样的,怎么办呢?
先谢谢了。
解决方案
涂料P =新的油漆();
p.setColor(Color.RED); TextView的T =(的TextView)findViewById(R.id.textview);
t.setPaintFlags(p.getColor());
t.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
t.setText(下划线文字);
作出新的油漆颜色。并指定油漆TextView的。
I know how to underline text in a textview. But how to underline text with some different color ? Underline can be done with:
TextView t = (TextView) findViewById(R.id.textview);
t.setPaintFlags(t.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
t.setText("Underline Text");
Let say my textcolor is black and I want to underline the same with blue color, how to do it ? Thanks in advance.
解决方案
Paint p = new Paint();
p.setColor(Color.RED);
TextView t = (TextView) findViewById(R.id.textview);
t.setPaintFlags(p.getColor());
t.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
t.setText("Underline Text");
make a new paint color. and assign the paint to the textview.
这篇关于如何强调文本的TextView与一些不同的颜色比文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文