TextView textView = new TextView(this);
String string = "Some String";
// to make it bold (or other styling)
SpannableString spanString = new SpannableString(string);
spanString.setSpan(new StyleSpan(Typeface.BOLD), 0, spanString.length(), 0);
// to allow autosize of texts
textView.setAutoSizeTextTypeWithDefaults(TextView.AUTO_SIZE_TEXT_TYPE_UNIFORM);
textView.setText(spanString);
textView.setTextColor(Color.BLUE);
Typeface appFont = getResources().getFont(R.font.oswald); // oswald
textView.setTypeface(appFont);
// centering texts
textView.setGravity(Gravity.CENTER);
// padding
textView.setPadding(10, 10, 10, 10);
// minimum width and hight
textView.setMinimumWidth(20);
textView.setMinimumHeight(20);
fontをAndroid Studioに追加するには
resフォルダ内にfontフォルダを作り、その中に.ttfファイルを置く
Typeface appFont = getResources().getFont(R.font.oswald);