0
0

More than 3 years have passed since last update.

AndroidのButtonのTextのスタイルを設定する方法

Last updated at Posted at 2020-08-27

概要

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);
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0