I seriously doubt the slowness in your application is a result of you using custom fonts. It's probably the way you're applying them. Typically, I'll do something like the following in my Activity:
//Get an instance to the root of your layout (outermost XML tag in your layout
//document)
ViewGroup root = (ViewGroup)findViewById(R.id.my_root_viewgroup);
//Get one reference to your Typeface (placed in your assets folder)
Typeface font = Typeface.createFromAsset(getAssets(), "My-Font.ttf");
//Call setTypeface with this root and font
setTypeface(root, font);
public void setTypeface(ViewGroup root, Typeface font) {
View v;
//Cycle through all children
for(int i = 0; i < root.getChildCount(); i++) {
v = root.getChildAt(i);
//If it's a TextView (or subclass, such as Button) set the font
if(v instanceof TextView) {
((TextView)v).setTypeface(font);
//If it's another ViewGroup, make a recursive call
} else if(v instanceof ViewGroup) {
setTypeface(v, font);
}
}
}
This way you keep only one reference to your Typeface, and you don't have to hard code any of your View IDs.
You can also just build this into a custom subclass of Activity
, and then have all of your Activites extend your custom Activity instead of just extending Activity, then you only have to write this code once.