Android设置字体
2015-10-29 00:00
357 查看
摘要: 我没有试过,只是觉得是一种积累。有兴趣可以自己试一下
自定义创建字型
//自定义字体字型
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:textAppearance 设置文字外观。如“?android:attr/textAppearanceLargeInverse ”这里引用的是系统自带的一个外观,?表示系统是否有这种外观,否则使用默认的外观。可设置的值如下:textAppearanceButton/textAppearanceInverse/textAppearanceLarge/textAppearanceLargeInverse/textAppearanceMedium/textAppearanceMediumInverse/textAppearanceSmall/textAppearanceSmallInverse textView.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));
相关文章推荐
- eclipse注释中的中文字体太小
- MyEclipse中设置全部字体大小
- 修改button上字体样式
- Eclipse背景颜色,字体大小,自定义格式化设置,自定义keys,自动注释,各大src源码下载,自定义注释
- Eclipse中java、jsp以及xml编辑界面字体设置
- Notepad++的字体设置为 Consolas 和微软雅黑混合字体<转载>
- Opera中文字体设置技巧总(字体大大小小)
- Linux下xterm字体设置
- eclipse怎么设置字体大小
- 移动web端开发字体设置问题,字体兼容性问题
- 更换字体
- IntelliJ IDEA相关背景字体设置
- Android应用修改字体
- 如何在wine下为Source Insight配置字体
- matplotlib之hist详解
- Android Studio中简单的设置-字体风格等
- pycharm安装设置
- 自用 VS2010 开发环境编辑风格 / .vssettings文件使用
- iOS开发 字体的几种设置方法
- CSS 文本样式(上)(20160817-0017)