I am trying to use the roboto fonts package for my android 2.3 app, but it does not add the fomarto letter. I've already tried using this code:
TextView tvTextView = ( TextView ) findViewById ( R . id . textView1 );
Typeface typeface = Typeface . createFromAsset ( getAssets (), "Roboto-Black.ttf" );
tvTextView . setTypeface ( typeface );
It does not apply the letter format, how do I rotate the sources roboto android 2.3?
Use this TextView instead:
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);
}
}
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.