在TextView里设置字体加粗分为两种方法,一种是在代码中动态添加,一种是在xml中静态添加
动态添加分两种方法:
1、
TextView textView = (TextView)findViewById(R.id.text_view);
TextPaint tp = textView .getPaint();
tp.setFakeBoldText(true);
2、(推荐)
TextView textView = (TextView)findViewById(R.id.text_view);
//设置为加粗
textView .setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
//设置为不加粗
textView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
静态方法:
android:textStyle="bold"