我正在实现一个拼写检查器,并想知道是否有一种简单/明显的方法可以用不同的颜色(例如红色)为某些文本加下划线。
我使用以下代码设置了所有内容并加下划线(还设置了文本的颜色):
private AttributeSet getAttributeSet(Color foregroundColor) {
SimpleAttributeSet attrs = new SimpleAttributeSet();
StyleConstants.setForeground(attrs, foregroundColor);
StyleConstants.setUnderline(attrs, true);
}
上面的代码将单词设置为蓝色,但也用蓝色下划线。我需要能够更改下划线及其厚度。有任何想法吗?
谢谢,