Using Fontawesome on Android

Source: Internet
Author: User

You don't have to do those nasty little icons anymore!

Find some information from the Internet, summarize the method of using Fontawesome on Android.

1. Download the resource bundle to the official website, locate the font file Fontawesome-webfont.ttf, and copy it into the assets of the program, in fact, this step is the same as using other fonts.

2.http://fontawesome.io/cheatsheet/to this site to query the Unicode of the icons you need.

3. You can create a subclass of TextView to set the font style uniformly, the code is as follows

 Public class Fontawesometextview extends TextView {    public  Fontawesometextview (context context, AttributeSet attrs) {        Super (context, attrs);         = Typeface.createfromasset (context.getassets (),                "Fontawesome-webfont.ttf " );          This . Settypeface (font);    }}

4. Replace TextView with a custom class in the XML you need

5. Set the content of the corresponding TextView

Call_icon_view.settext (html.fromhtml ("& #xf095; "));

Note that this cannot be directly set to "& #xf095;", need to use Html.fromhtml ("& #xf095;"), the underlying cause to study!

Using Fontawesome on Android

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.