//自定义字体字型
custom=new TextView(this);
//字体MgOpenCosmeticaBold.ttf放置于assets/font/路径下
typeface=Typeface.createFromAsset(getAssets(),"font/MgOpenCosmeticaBold.ttf");
custom.setTypeface(typeface);
custom.setText("Custom Font FYI");
custom.setTextSize(20.0f);
//设置字体颜色
custom.setTextColor(Color.CYAN);
linearLayout.addView(custom,new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
Android换字体
最新推荐文章于 2021-05-26 02:34:31 发布