Iconfont tips for using Android apps

Source: Internet
Author: User

1, about Iconfont

Iconfont is both icon and font, in particular, it should be displayed in the form of a font icon. Unlike icons in traditional picture formats, this kind of icon is easy to change in size, color, and background color because it is displayed in font form.

2. How to use 2.1 Download resources

Resource Source: http://www.androidicons.com/

Follow the guide to find the download link. Download the decompression to find Iconfont/font, the inside of the four files copied to the Android project in the assets directory. Find glyphs/glyphs.html, because it will be used later, so it is also copied to the assets directory.

2.2 Adding icons

Here add TextView, button and other controls can, and then SetText () when the icon corresponding to the code as a parameter to pass in. For the icon corresponding to the code, you need to open glyphs.html, find the icon you want to add, copy the last line below, such as "& #59428;".

2.3 Setting fonts (Typeface)
Typeface icontypeface = Typeface.createfromasset (Getassets (), "Androidicons.ttf"= (TextView) Findviewbyid (R.id.iconview); Textview.settypeface (icontypeface);

Typeface.createfromassets () The first parameter is the Assetmanager object, which is obtained by Getassets (), and the second parameter is the path, as shown in the code as "Assets/androidicons.ttf".

Note: When I use eclipse, I don't see the added icon in the preview, only in the emulator, and I don't know if it's the eclipse itself.

Iconfont tips for using Android apps

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.