Android设置字体
16lz
2021-01-23
android:textAppearance设置文字外观。如“?android:attr/textAppearanceLargeInverse”这里引用的是系统自带的一个外观,?表示系统是否有这种外观,否则使用默认的外观。可设置的值如下:textAppearanceButton/textAppearanceInverse/textAppearanceLarge/textAppearanceLargeInverse/textAppearanceMedium/textAppearanceMediumInverse/textAppearanceSmall/textAppearanceSmallInversetextView.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);//下划线textView.getPaint().setAntiAlias(true);//抗锯齿textview.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);//中划线setFlags(Paint.STRIKE_THRU_TEXT_FLAG|Paint.ANTI_ALIAS_FLAG);//设置中划线并加清晰textView.getPaint().setFlags(0);//取消设置的的划线
自定义创建字型
//自定义字体字型
custom=newTextView(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,newLinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
更多相关文章
- android实现字体闪烁动画的方法
- Android修改字体样式
- Android引入外部字体源代码
- Android部分字体高亮
- android spinner 选中后显示字体的颜色设置
- android 根据TextView宽度 自动缩小字体大小 以适应其宽度
- Android 字体效果:描边、浮雕效果
- android studio 更改背景和设置字体大小
- 【Android 界面效果42】如何自定义字体