0

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?

Volker E.
  • 5,911
  • 11
  • 47
  • 64

1 Answers1

0

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...

Community
  • 1
  • 1
Nadeem Iqbal
  • 2,357
  • 1
  • 28
  • 43