在xml文件中使用android:textStyle="bold" 可以将英文设置成粗体,但是不能将中文设置成粗体,将中文设置成粗体的方法是:
TextView tv = (TextView)findViewById(R.id.TextView01);
TextPaint tp = tv.getPaint();
tp.setFakeBoldText(true);
其他还有:
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24f);//设置成24sp
textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));//可能中文加粗无效
textView.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC));//可能中文无效
textView.setText(Html.fromHtml(""+texts+""));//下划线
textView.setTypeface(Typeface.MONOSPACE,Typeface.ITALIC);//斜体,中文有效
textView.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG );//中间加横线
textView.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG );//底部加横线

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-05
  • 2021-11-16
  • 2022-12-23
  • 2021-05-16
  • 2021-11-27
  • 2022-01-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案