1

I am using a typeface as well as i want to make it bold but its not getting bold, how to set the text style when if set a typeface in text.

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);
Muhammad Aamir Ali
  • 20,419
  • 10
  • 66
  • 57

3 Answers3

1

Instead of:

dialog_text.setTypeface(Typeface.DEFAULT_BOLD);

use:

Typeface century_gothic_bold = Typeface.create(century_gothic, Typeface.BOLD);  
dialog_text.setTypeface(century_gothic_bold);
Piotr Chojnacki
  • 6,837
  • 5
  • 34
  • 65
0

Use something like:

dialog_text.setTypeface(CustomDialog.century_gothic | Typeface.DEFAULT_BOLD);
yugidroid
  • 6,640
  • 2
  • 30
  • 45
0

use getTypeface() method like this:

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);
Keyur Lakhani
  • 4,321
  • 1
  • 24
  • 35