1

我正在使用一种字体,并且我想让它变粗但它不会变粗,如果在文本中设置字体,如何设置文本样式。

century_gothic = Typeface.createFromAsset(context.getAssets(), "century_gothic.ttf");
TextView dialog_text = (TextView)layout.findViewById(R.id.textdialog);
dialog_text.setText(text);
dialog_text.setTypeface(CustomDialog.century_gothic);
dialog_text.setTypeface(Typeface.DEFAULT_BOLD);
4

3 回答 3

1

代替:

dialog_text.setTypeface(Typeface.DEFAULT_BOLD);

利用:

Typeface century_gothic_bold = Typeface.create(century_gothic, Typeface.BOLD);  
dialog_text.setTypeface(century_gothic_bold);
于 2013-06-27T12:19:40.003 回答
0

使用类似的东西:

dialog_text.setTypeface(CustomDialog.century_gothic | Typeface.DEFAULT_BOLD);
于 2013-06-27T12:23:02.770 回答
0

像这样使用getTypeface()方法:

dataTitle = (TextView)itemView.findViewById(R.id.dataTitle);
font = Typeface.createFromAsset(itemView.getContext().getAssets(), "fonts/ArchitectsDaughter.ttf");
dataTitle.setTypeface(font);
dataTitle.setTypeface(dataTitle.getTypeface(),Typeface.BOLD);
于 2016-02-02T08:14:39.247 回答