这个只是做一个笔记,详情见代码:
代码中的注释也有说明。
TextView textView = (TextView) findViewById(R.id.textView1);
SpannableStringBuilder sb = new SpannableStringBuilder("abcdefghijklmnopqrst."); // 包装字体内容
ForegroundColorSpan fcs = new ForegroundColorSpan(getResources().getColor(R.color.yellow_orange)); // 设置字体颜色
StyleSpan bss = new StyleSpan(android.graphics.Typeface.BOLD); // 设置字体样式
AbsoluteSizeSpan ass = new AbsoluteSizeSpan(140); // 设置字体大小
sb.setSpan(fcs, 0, 10, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
sb.setSpan(bss, 0, 20, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
sb.setSpan(ass, 0, 5, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(sb);运行结果如下:

转载于:https://www.cnblogs.com/fengju/p/6336141.html
最后
以上就是潇洒洋葱最近收集整理的关于Android中对同一个TextView设置不同字体样式的全部内容,更多相关Android中对同一个TextView设置不同字体样式内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复