简体   繁体   中英

font -family roboto android 2.3.3

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?

There is no other way of doing this for API 11< With out including the font file in assets

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

see full answer here ...

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