Code Monkey home page Code Monkey logo

android-textview-custom-fonts's Introduction

Android TextView Custom Fonts

Small sample that allows to use custom font in layout.xml and style.xml for Android TextView. Implementation holds all loaded fonts in memory relative to Application context.

If it is desired to hold only limited number of fonts "loaded" cache = new LruCache<String, Typeface>(MAXIMUM_NUMBER_OF_LOADED_FONTS) can be used instead of HashMap in CustomFontFactory.

More sophisticated schemes of shared font cache management can be implemented but it is outside of the scope of this sample.

CustomFontFactory is a shared singleton that is used in BaseActivity. It does not have any provisions for thread safety thus it must be used on application main thread.

This sample code is tested on Android API 12 (Honeycomb 3.1) to 19 and guaranteed not to work for API <= 11 (Honeycomb 3.0) see: http://en.wikipedia.org/wiki/Android_version_history

Free fonts used in sample assets are http://www.fontsaddict.com/font/baroque-script.html http://www.fontsaddict.com/font/curvaceous-script-regular.html http://www.fontsaddict.com/font/dagerotypos.html

If you have any questions/suggestions/improvements feel free to contact me at

[email protected]

alt tag

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.