Embedded font in Android for personalization

Source: Internet
Author: User

In Android, our applications can flexibly embed their own font files to enable normal display of personalized text on various mobile phones. We all know that the settypeface method of textview can set the display characteristics of the target text, such as font, color, bold, and italic. We can directly find a truetypefont font file named. TTF. for Win32 users, you can find a lot in the Windows/fonts folder. For example, is good, but the size is too large. Because the android assets class has a size limit of 1 MB for a single file, we should first find an English font for testing. Here we place the font file android123.ttf In the fonts directory of the assets folder of the project.

Typeface TF = typeface. createfromasset (getassets (), "fonts/android123.ttf ");
Textview TV = (textview) findviewbyid (R. Id. Text );

TV. settypeface (TF); // sets the textview style.
TV. settext ("cwj test ");
TV. settextsize (12 );
TV. settextcolor (color. Red );

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.