概要
AndroidのButton内のTextのスタイルを設定する方法をまとめる。
注意点
AndroidStudioではimport文の追加が自動で行われなかった。
以下のimport文を自分で以下を追記する必要がある。
import android.graphics.Typeface;
スタイルの設定方法
import android.graphics.Typeface;
Button btn = (Button) findViewById(R.id.button);
// テキストをNormalに変更
btn.setTypeface(null, Typeface.DEFAULT);
// テキストをBoldに変更
btn.setTypeface(null, Typeface.DEFAULT_BOLD);
// テキストをBold + Italicに変更
btn.setTypeface(null, Typeface.DEFAULT_BOLD_ITALIC);
// テキストをItalicに変更
btn.setTypeface(null, Typeface.DEFAULT_ITALIC);