Is it possible to set font for entire Application?
来源:互联网 发布:写论文查数据的网站 编辑:程序博客网 时间:2024/05/18 04:43
From:http://stackoverflow.com/questions/2711858/is-it-possible-to-set-font-for-entire-application
Question:
Hi,
I need to use certain font for my entire application. I have .ttf file for the same. Is it possible to set this as default font, at application start up and then use it elsewhere in the application? When set, how do i use it in my layout XMLs?
Sample code, tutorial that can help me here is appreciated.
Thanks.
Answer:
Yes, its possible to set the font to the entire application.
The easiest way to accomplish this is to package the desired font(s) with your application.
To do this, simply create an assets/ folder in the project root, and put your fonts (in TrueType, or TTF, form) in the assets.
You might, for example, create assets/fonts/ and put your TTF files in there.
**public class FontSampler extends Activity { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); TextView tv=(TextView)findViewById(R.id.custom);
Typeface face=Typeface.createFromAsset(getAssets(), "fonts/HandmadeTypewriter.ttf"); tv.setTypeface(face); } }- Is it possible to set font for entire Application?
- Is it possible to simulate a new addressing scheme for MANETs using GNS3 ?
- Is it possible to alias a branch in Git?
- Installation failed with message Failed to establish session. It is possible that this issue is reso
- 如何为VS创建排序并移除不必要的命名空间引用-Is it possible to create a shortcut for removing unused usings into a class?
- Is it possible to make asp.net themes available to all sites on the sever?
- Is it possible to assign a UTexture2D to a material at runtime?
- It's also possible to employ the book for you to influence
- DFS单向复制的疑问/Is it possible to configure one-way replication with DFS Replication?
- Is it possible to get the difference from two dynamic arrays regardless of their order?
- Is it possible to display icons in a PopupMenu?PopupMenu中显示图片是否可能
- Is it possible to let gcc 4.7 and gcc 4.8 co-exist
- ”***" isn't code signed but requires entitlements. It is not possible to add entitlements
- Is it possible to implement IPv6 on a virtual interface (eth0:1 interface) in Linux?
- Installation failed with message Failed to establish session. It is possible...
- IELTS12 Test5 It is good to share as much information as possible in any areas
- It's possible your PC or network is sending automatic requests. To continue, please enter following
- "AND" in linq? is it possible?
- Linux下打包压缩war和解压war包
- 隐式类类型转换
- android manifest.xml中元素含义
- 连接mysql数据库
- Make your Android Listview Fast and Efficient
- Is it possible to set font for entire Application?
- 网上下载了万辰OA系统V4.5版本,所谓的注册破解版
- tyvj P1067:合唱队形
- How to use the date format that has been setup as default in Settings?
- 总结、搜集、疑问贴 关于数据的转移
- getvolumenameforvolumemountpoint VC6提示该函数未定义
- Android - what’s the difference between the various methods to get a Context?
- Debug Android Source Builds
- Javascript_MD5