Custom Fonts in Android - w2class

Custom Fonts in Android - w2class

In this post, we’ll look at a generalized approach, which is more complex, but also more suitable for a repeated use of custom fonts.

Extending TextView

We’ll create a new Java class, which extends TextView. This allows us to use that class in all XML views. It inherits all functionality and properties of a regular TextView but adds our custom font.

You can see in detail : - click here

The first three methods are just constructors, which we override to call a single method applyCustomFont(). That method is the important piece of the puzzle. Lastly, we’ve to call setTypeface() with the font and we’re almost done. In case you’re wondering, we can call the setTypeface() directly (and not on a TextView object), since we’re extending the TextView class.

Using the Class

You might wonder, if so much preparation is worth the effort. In this section you’ll see that it is indeed. Because all you’ve left to do is use the class in an XML view and it automatically has your custom font. There is no Java code necessary.

You can see in detail : - click here

要查看或添加评论,请登录

Peeyush Singhal的更多文章

  • Kiodesk : A Custome Support Software

    Kiodesk : A Custome Support Software

    KioDesk helps businesses deliver outstanding customer support to their clients through tools that allow customers to…

  • Roboeyelabs : A Online Free CRM Software

    Roboeyelabs : A Online Free CRM Software

    Customer relationship management (CRM) manages your business's single most important goal - satisfying your customers…

  • Sign Up for Best Free Bug Tracking Software | Bugcutter

    Sign Up for Best Free Bug Tracking Software | Bugcutter

    Bugcutter is a cloud based Bug Tracking and Project management tool. You can manage your projects here in a simplest…

  • Bugcutter - A Cloud based Project Management Tool

    Bugcutter - A Cloud based Project Management Tool

    Bugcutter is A cloud based bug tracking and project management tool . It is kanban based simple and free tools to…

  • PK Player - Android app

    PK Player - Android app

    Stylish , Powerful and Fast Music Player with elegant design . Music Player lets you manage all your music files…

  • Grow Your Business With Android Apps

    Grow Your Business With Android Apps

    Android has emerged as the most popular mobile operating system in the world. With more than 1 billion active Android…

  • Music Library for Android

    Music Library for Android

    This is the music library for android. You can use this library by just download and import in your android project.

    1 条评论
  • AppLocker - Android application

    AppLocker - Android application

    AppLocker is an application which is used to keep your privacy. You can lock your applications in your phone.

  • How to Get List of Installed Apps in Android

    How to Get List of Installed Apps in Android

    How to Get List of Installed Apps in Android Android PackageManager class is used to retrieve information on the…

  • Android SQLite Database Tutorial - w2class

    Android SQLite Database Tutorial - w2class

    SQLite is a opensource SQL database that stores data to a text file on a device. Android comes in with built in SQLite…

社区洞察

其他会员也浏览了