android设置textView部分字体加粗 添加颜色 简便方法
重点使用了Html.fromHtml方法,示例代码如下:
@BindView(R.id.myTextView)
TextView myTextView;
myTextView.setVisibility(View.VISIBLE);
String content = "截止日期:<font color='#ff9e30'>2022-05-15</font>";
myTextView.setText(Html.fromHtml(content));
myTextView.getPaint().setFakeBoldText(true);//设置字体加粗
第二种方法是使用span,需要截取字符串比较麻烦在此就不在举例了。