Android Platform Fonts PRO

The android platform already comes with the following predefined fonts: “sans”,”serif” and “monospace”. The android platform allows us to add and use new fonts within the application we develop. In order to use a specific font we just need to reference it within the XML layout document. Adding the android:typeface attribute into the view XML element and specify the font name as its value does the trick. The following sample shows how to specify the usage of the “serif” font in a specific text view.

The simplest way to use a new font in our application is adding the required TTF font file to the assets folder of our application and loading it in our code. The following code sample uses the Ansshenkin.ttf free hebrew font you can download at http://fonti.come2us.co.il/fonts.htm.

The following code samples creates a new TypeFace object that represents the Ansshenkin font. Placing the Ansshenkin.ttf file within the application assets folder we can easily load it into our code and create a new TypeFace object based on its data. The TypeFace.createFromAsset() static method loads the Ansshenkin.ttf file from the assets folder and creates a new TypeFace object based on the data that file includes.

The text this application shows was saved separatedly within the strings.xml resource file.

The following screenshot was taken when running this application. The displayed text is the hebrew word for peace.

Press here to download the files of this application.

Share:

The Visitor Design Pattern

The Visitor Design Pattern

The visitor design pattern allows us to add operations to objects that already exist without modifying their classes and without extending them.

What are Anti Patterns?

Anti Patterns

Unlike design patterns, anti patterns just seem to be a solution. However, they are not a solution and they cause additional costs.

Virtual Threads in Java Professional Seminar

Virtual Threads in Java

The use of virtual threads can assist us with improving the performance of our code. Learn how to use virtual threads effectively.

NoSQL Databases Courses, Seminars, Consulting, and Development

MongoDB Design Patterns Meetup

The use of MongoDB involves with various cases in which we can overcome performance issues by implementing specific design patterns.

image of woman and database

Record Classes in Java

Learn how to define record classes in Java, and when to use record classes in your code. Stay up to date with the new Java features.

Accessibility | Career | Conferences | Design Patterns | JavaScript | Meetups | PHP | Podcasts | Python | Self Learning

Teaching Methodologies | Fullstack | C++ | C# | CSS | Node.js | Angular | Java | Go | Android | Kotlin | Swift | Academy

Front End Development | Scala | Architectures | Cloud | Big Data | Internet of Things | Kids Learn Programming

The Beauty of Code

Coding is Art! Developing Code That Works is Simple. Develop Code with Style is a Challenge!

Skip to content Update cookies preferences