拨电话、下划线等处理方法
1、再xml文件中配置
如:<string name="hello"><u>phone: 1390123456</u></string>
2、再代码中配置
如:
//拨电话 SpannableStringBuilder ss = new SpannableStringBuilder(text); ss.setSpan(new URLSpan("tel:"+text), 0, text.length() , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setText(ss); textView.setText(Html.fromHtml("<u>"+text+"</u>"));//下划线
//配置颜色 ss.setSpan(new ForegroundColorSpan(Color.RED), 0, 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); //斜体 ss.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), 5, 7, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); //删除线 ss.setSpan(new StrikethroughSpan(), 7, 10, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); //下划线 ss.setSpan(new UnderlineSpan(), 10, 16, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); //背景 ss.setSpan(new BackgroundColorSpan(Color.rgb(124, 156, 215)), 15, 17, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);