简体   繁体   中英

How to set double text style in textview in android?

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);

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);

使用类似:

dialog_text.setTypeface(CustomDialog.century_gothic | Typeface.DEFAULT_BOLD);

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM