You can do this easily by using the Typerlib.
This library wraps the complexity of adding a font resource in your
project and recycle those recently created font inorder to maximize
your app's perfromance.
Add this to your build.gradle
dependencies {
compile 'com.elmargomez.typer:typerlib:1.0.0'
}
Then you can use the font by
TextView txtView1 = (TextView) findViewById(R.id.yourTxtView1);
TextView txtView2 = (TextView) findViewById(R.id.yourTxtView2);
TextView txtView3 = (TextView) findViewById(R.id.yourTxtView3);
TextView txtView4 = (TextView) findViewById(R.id.yourTxtView4);
txtView1.setTypeface(Typer.set(yourContext).getFont(Font.ROBOTO_REGULAR));
txtView2.setTypeface(Typer.set(yourContext).getFont(Font.ROBOTO_CONDENSED_ITALIC));
txtView3.setTypeface(Typer.set(yourContext).getFont(Font.ROBOTO_THIN));
txtView4.setTypeface(Typer.set(yourContext).getFont(Font.ROBOTO_BOLD));
It includes all the current fonts in Roboto
,Like:
Font.ROBOTO_MEDIUM
Font.ROBOTO_REGULAR
etc.
To view all available fonts use Android Studio Auto complete after the class Font by pressing Ctrl + space.