Is it possible to set font for entire Application?
2010-08-27 20:19
465 查看
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); } }
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); } }
相关文章推荐
- The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the ser
- 遇到WARNING:Could not lower the asynch I/O limit to 170 for SQL direct I/O. It is set to -1
- Oracle Bug: WARNING:Could not lower the asynch I/O limit to 224 for SQL direct I/O. It is set to -1
- 如何为VS创建排序并移除不必要的命名空间引用-Is it possible to create a shortcut for removing unused usings into a class?
- WARNING:Could not increase the asynch I/O limit to 64 for SQL direct I/O. It is set to 0
- WARNING:Could not increase the asynch I/O limit to 64 for SQL direct I/O. It is set to 0
- Eclipse调试时Application XXX is waiting for the debugger to attach的提示
- yum提示another app is currently holding the yum lock;waiting for it to exit
- Unable to add window -- token null is not for an application
- Android错误之--Platform MNC is a preview and requires application manifest to set minSdkVersion to 'MNC
- Unable to add window -- token null is not for an application
- Is it possible to change A Menu Item's Type?
- android异常:application Test is waiting for debugger to attach
- 关于 Unable to add window -- token null is not for an application 错误的解决方法
- Unable to add window -- token null is not for an application
- [已解决]Android 5.1 上面进行debug的时候 debug 的界面总是不消失 一直显示 Application is waiting for the debugger to attach
- ArcGIS Engine中初始化许可常见问题归纳,the application is not licensed to create or modify schema for this type of data
- Is it harder to learn English for an adult?
- This file is set to build for a version older than the project deployment target. Functionality may
- 安装Visual Studio 2010时提示"The location specified for the help content store is invalid or you do not have access to it".