android TextView改变部分字体的颜色,大小,设置部分字体有点击事件
SpannableString ss = new SpannableString("lsjfkdsjfksfjkfjsdkfjfjsdkskfsdfds");
ss.setSpan(new ClickableSpan() {
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
//设置无下划线
ds.setUnderlineText(false);
}
@Override
public void onClick(View widget) {
System.out.println("============================");
Log.i("", "===========================");
}
}, 5, 15, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
et.setText(ss);
//设置字体点击后无颜色
et.setHighlightColor(Color.TRANSPARENT);
//这段必须加上才会有点击事件
et.setMovementMethod(LinkMovementMethod.getInstance());