Android Guide: How to draw text over bitmap


Last Updated on

We’ve all been there,… reducing the number of overdraws or customizing image with little to none external libraries. This modern twist to this (and this) age-old article will surely help you with that.

I’ve managed to rewrite the example code in Kotlin so it’s far more readable than Java-stic code and you can understand what is really going on just by glancing over it.

bitmap programming

It is however backward compatible with Java, don’t you worry! It utilizes simple builder which gets you to set up quickly and you’ll get things done with just a few lines.

This is how it works:

  1. After you create the instance of DrawingConfig, it automatically sets default values to avoid nullability issues.
  2. You just set your paint, text and a background and call draw() , it spits out Bitmap with text on top of it just like a magic spell.
  3. (Non-mandatory step) You can adjust how the text is painted or even add own layout with some other content by calling draw {} , it gives you the instance of current DrawingValues and you are free to position the text wherever you like.

No further delay, here’s the code!

Whenever you feel like you would do something better, ping me in comments so others don’t do the same mistakes by copy-pasting this code.


Viktor De Pasquale


Author picture

You’re on top of the game. Thanks for shgarni.

Load more
Leave a comment

In order to allow our CI server to deploy applications on Google Play automatically, we have to generate the JSON key. Thanks to this key, we can quickly deploy applications without manually uploading each and every version. We can also control what version we did upload on Google Play through our ...

Read post

The Czech vocabulary-building app Vocabulary Miner created by studio SKOUMAL is based on the popular Flashcard System and special algorithm.  It promises the user to simply say more with every word and delivers it through effective, yet simple vocabulary training by ...

Read post

Listed among the best app developers in the Czech Republic, we’re excited to announce that we’ve won a 2019 Clutch leader award!   Known best as the leading platform for ratings of B2B service providers, Clutch reviews help businesses connect with the best-fit agency ...

Read post

[caption id="attachment_2730" align="aligncenter" width="1024"] Photo by Farzad Nazifi on Unsplash[/caption]   Every Android app has its unique identifier called applicationId and you have to choose it wisely because it cannot be changed later. Here are two main reasons ...

Read post