Android设置字体
16lz
2021-12-10
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音频、视频、拍照基础操作
- 复习TextView(查漏补缺)
- Android(安卓)ScrollView包裹EditText 软键盘弹出后,ScrollView
- android 触发AppWidget上控件事件来更新AppWidget
- Android黑科技 自动点击
- android shape的使用
- Android(安卓)setMovementMethod() 方法
- 代码实现android手机信号监听
- Android(安卓)settings使用详解之设置优先网络