简体   繁体   English

如何在Android的TextView中设置双重文本样式?

[英]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: 使用如下的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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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