首页 > 代码库 > TextView 下划线/字体/颜色

TextView 下划线/字体/颜色

TextView txtShuoming;
SpannableStringBuilder builder = 
		new SpannableStringBuilder(getResources().getString(R.string.shuoming));
//1.设置字体颜色                 builder.setSpan(new ForegroundColorSpan(Color.BLUE), 47,56, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
//2.设置字体风格
   		 builder.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 237, 241,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
              
		 txt.setText(builder);

//3.设置下划线
		   txt.setText(Html.fromHtml("<u>"+ getResources().getString(R.string.shuoming) + "</u>"));