今天遇到这个问题,及时记录下来。
配置文件中加粗
<TextView android:id="@+id/tv_followup_day_unit" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/tv_followup_day" android:layout_marginLeft="1dp" android:textColor="@color/user_space_reservation_day_value" android:textStyle="bold" android:textSize="10sp" android:text="天后" />
在搜索里面看到的答案都是
tvShowData.getPaint().setFakeBoldText(true);
这种方法经本人不断测试,始终不得行。
最后采用下面的方式,得以成功解决问题:
SpannableString spanString = new SpannableString(userStatus); StyleSpan span = new StyleSpan(Typeface.BOLD); spanString.setSpan(span, 0, spanString.length(), Spannable.SPAN_COMPOSING); tvShowData.setText(spanString);