Android/独自font
提供: 初心者エンジニアの簡易メモ
独自フォントをテキストに表示するサンプル
コード
TextView textView = findViewById(R.id.text01);
Typeface font = Typeface.createFromAsset(getAssets(), "fonts/font.ttf");
textView.setTypeface(font);
textView.setText("sample\uF107"); // sampleの後にフォントが出る
レイアウト
<TextView
android:id="@+id/text01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
フォントを置く場所
src/main/assets/font/hoge.ttf
pcにfontがインストールされていなくても問題なく表示される
