Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Created October 23, 2020 06:42
Show Gist options
  • Save codeforfun-jp/d4a04c3d88a834b66f2bd86167c7a76a to your computer and use it in GitHub Desktop.
Save codeforfun-jp/d4a04c3d88a834b66f2bd86167c7a76a to your computer and use it in GitHub Desktop.
Custom Font (Java)
package jp.codeforfun.customfont;
import androidx.appcompat.app.AppCompatActivity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Typeface customFont = Typeface.createFromAsset(getAssets(), "Sofia-Regular.ttf");
TextView myText = findViewById(R.id.myText);
myText.setTypeface(customFont);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment