Don't talk nonsense, let's go to the picture first
1. Create a new fonts file under assets, and put the font style.TTF file into it
2. Code part
@BindView(R.id.tv_tv)
TextView tvTv;
@BindView(R.id.tv_tv1)
TextView tvTv1;
@BindView(R.id.tv_tv2)
TextView tvTv2;
@BindView(R.id.tv_tv3)
TextView tvTv3;
AssetManager assets = getAssets();
Typeface tf = Typeface.createFromAsset(assets, "fonts/milaiti.ttf");
tvTv.setTypeface(tf);
Typeface tf1 = Typeface.createFromAsset(assets, "fonts/hua_kang_zhong_yi.ttf");
tvTv1.setTypeface(tf1);
Typeface tf2 = Typeface.createFromAsset(assets, "fonts/terminator_real_nfi.ttf");
tvTv2.setTypeface(tf2);
Typeface tf3 = Typeface.createFromAsset(assets, "fonts/hua_kang_girl.ttf");
tvTv3.setTypeface(tf3);
The above code can realize the special font style, and the layout part is too simple to paste it out.
If you want your own TextView fonts to display the desired special style first, you can inherit TextView and re-customize View.
Custom TextVIew code
package com.bang.myapplication;
import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Typeface;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
/**
* DateTime: 2019/4/17 19:07
* author: Bang
* description: 特殊字体样式
*/
public class TffTextView extends android.support.v7.widget.AppCompatTextView {
public TffTextView(Context context) {
super(context);
}
public TffTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void setTypeface(@Nullable Typeface tf) {
AssetManager assets = getContext().getAssets();
tf = Typeface.createFromAsset(assets, "fonts/hua_kang_girl.ttf");
super.setTypeface(tf);
}
}
layout reference
<com.bang.myapplication.TffTextView
android:id="@+id/tff_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/zyfc"
android:textSize="30sp"/>
The above font style download address
https://download.csdn.net/download/qq_37686995/11123431