外部フォントを使用しようとしていますが、誰かの答えを使用しましたが(どこから覚えていないのでしょうか)、起動時にクラッシュします。外部フォントを使用する
私はfont.ttfファイル入れている私は基本的に、資産/フォントフォルダを持っている:これはTextViewのためのXMLコードである https://i.gyazo.com/2010d3becbabbab35fc8738a6a30689b.png
を:
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text Here."
android:textSize="30dp"
android:layout_marginTop="120dp"
android:textAlignment="center"
android:id="@+id/howtotv"/>
そして、これは、Javaで私はフォントを割り当てるしようとしていますそのためのコード、:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.howtoplay);
MyTV = (TextView) findViewById(R.id.howtotv);
Typeface typeface=Typeface.createFromAsset(getAssets(), "fonts/archristy.ttf");
MyTV.setTypeface(typeface);
}
私は取得していますエラー:
エラー:タスク ':app:packageDebug'の実行に失敗しました。
java.io.FileNotFoundException: D:\AndroidStudioProjects\Tapper2\app\build\intermediates\assets\debug\fonts (access denied)
フォントフォルダのarchristy.ttfファイルを確認 –