オリジナルフォントを使う

TextViewにオリジナルフォントを指定し、表示する。

    •     ① 使いたいFontファイルを用意する。
          ② プロジェクトフォルダ直下の assets フォルダに fonts フォルダを作成し、その中に上記 Font ファイルを格納。
          ③ Activity に以下のように記述。
  • // assets から Typeface を作成
    Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/font.ttf");
    
    // Typeface  を TextViewに指定
    TextView text= (TextView)findViewById(R.id.text);
    if(typeface != null && text!= null )text.setTypeface(typeface);
    Typeface(API Level1-)
    Font の固有のスタイルや Typeface を指定する。

    Ref.) Android Developers>Typeface