![](/img/trans.png)
[英]How to set Roboto variant font family to a Textview in android?
[英]font -family roboto android 2.3.3
我正在尝试为我的android 2.3应用程序使用roboto字体包,但未添加fomarto字母。 我已经尝试使用以下代码:
TextView tvTextView = ( TextView ) findViewById ( R . id . textView1 );
Typeface typeface = Typeface . createFromAsset ( getAssets (), "Roboto-Black.ttf" );
tvTextView . setTypeface ( typeface );
它不应用字母格式,我该如何旋转信号源roboto android 2.3?
使用此TextView代替:
public class TextView_Roboto extends TextView {
public TextView_Roboto(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
createFont();
}
public TextView_Roboto(Context context, AttributeSet attrs) {
super(context, attrs);
createFont();
}
public TextView_Roboto(Context context) {
super(context);
createFont();
}
public void createFont() {
Typeface font = Typeface.createFromAsset(getContext().getAssets(), "robo_font.ttf");
setTypeface(font);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.