AIM : How to use Custom fonts programatically in android
Solution:
Step 1) Download any font from internet
for example use this link to check some fonts( http://www.urbanfonts.com/free-fonts.htm )
and Save it in assets folder of the project .
Step 2) use the following lines
Creating a typeface object from assets folder
Typeface fontFace = Typeface.createFromAsset(getAssets(), "xtrusion.ttf");
Step 3) create a textview and apply the above typeface object to textview.
TextView someText = (TextView)findViewById(R.id.TextView01);
use any of the following methods to set typeface for textview.
someText.setTypeface(fontFace); // only typeface
someText.setTypeface(fontFace, TextUtils.CAP_MODE_CHARACTERS); // typeface with style properties.
By this way we can apply different fonts for our projects in android.
Monday, August 9, 2010
Subscribe to:
Post Comments (Atom)
Android Developers Blog
- The Third Beta of Android 16 - 3/13/2025
- #TheAndroidShow: Multimodal for Gemini in Android Studio, news for gaming devs, the latest devices at MWC, XR and more! - 3/13/2025
- Multimodal image attachment is now available for Gemini in Android Studio - 3/13/2025
- Building excellent games with better graphics and performance - 3/13/2025
- Making Google Play the best place to grow PC games - 3/13/2025
No comments:
Post a Comment