📜  如何在java代码示例中将自定义字体更改为粗斜体

📅  最后修改于: 2022-03-11 14:52:06.091000             🧑  作者: Mango

代码示例1
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Typeface font = Typeface.createFromAsset(getAssets(), "fonts/bebas_neue_regular.ttf");

        TextView tvNormal = (TextView) findViewById(R.id.normal);
        tvNormal.setTypeface(font);

        TextView tvBold = (TextView) findViewById(R.id.bold);
        tvBold.setTypeface(font, Typeface.BOLD);

        TextView tvItalic = (TextView) findViewById(R.id.italic);
        tvItalic.setTypeface(font, Typeface.ITALIC);


        TextView tvBoth = (TextView) findViewById(R.id.boldItalic);
        tvBoth.setTypeface(font, Typeface.BOLD_ITALIC);
    }
}