この文書の現在のバージョンと選択したバージョンの差分を表示します。
| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
|
android:viewのフォント追加 [2019/11/15 23:51] ips |
android:viewのフォント追加 [2019/11/16 00:28] (現在) ips [ビルドツールのインストール] |
||
|---|---|---|---|
| ライン 76: | ライン 76: | ||
| implementation 'uk.co.chrisjenx:calligraphy:2.3.0' | implementation 'uk.co.chrisjenx:calligraphy:2.3.0' | ||
| - | # 使いたいアクティビティに追加 | ||
| - | <code> | ||
| - | override fun attachBaseContext(newBase: Context) { | ||
| - | super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase)) | ||
| - | } | ||
| - | </code> | ||
| - | |||
| - | # レイアウトに追加 | ||
| - | <code> | ||
| - | <androidx.appcompat.widget.AppCompatTextView | ||
| - | android:fontFamily="font/ayu20gothic-1.7a.ttf" | ||
| - | android:layout_width="match_parent" | ||
| + | <code> | ||
| + | val am = this.getApplicationContext().getAssets() | ||
| + | val typeface = Typeface.createFromAsset(am,String.format(Locale.US, "font/%s", "shnm6x12a.ttf")) | ||
| + | |||
| + | もしくは | ||
| + | |||
| + | val custom_font = Typeface.createFromAsset(assets, "font/shnm6x12a.ttf") | ||
| + | |||
| + | ↓ | ||
| + | |||
| + | holder.textTitle?.typeface=typeface | ||
| + | holder.textSub?.typeface=typeface | ||
| </code> | </code> | ||
| + | |||