Alex Rivera | Logout

Android - Using Custom Font

Asked 2010-09-06T11:33:44.613
269

I applied a custom font to a TextView, but it doesn't seems to change the typeface.

Here is my code:

    Typeface myTypeface = Typeface.createFromAsset(getAssets(), "fonts/myFont.ttf");
    TextView myTextView = (TextView)findViewById(R.id.myTextView);
    myTextView.setTypeface(myTypeface);

Can anyone please get me out of this issue?

Edit
Report

2 Answers

1

I had the same problem, the TTF did not show up. I changed the font file, and with the same code it's working.

answered 2013-05-18T19:54:37.603
1

If you want to load the font from the network or easily style it, you can use:

https://github.com/shellum/fontView

Example:

<!--Layout-->
<com.finalhack.fontview.FontView
        android:id="@+id/someFontIcon"
        android:layout_width="80dp"
        android:layout_height="80dp" />

//Java:
fontView.setupFont("http://blah.com/myfont.ttf", true, character, FontView.ImageType.CIRCLE);
fontView.addForegroundColor(Color.RED);
fontView.addBackgroundColor(Color.WHITE);
answered 2013-05-29T21:13:37.297

Your Answer