# TextDrawable: Generating Letter Tiles as Android Drawables

> TextDrawable is a small Java library for Android that turns a letter or short string into a colored drawable, styled like Gmail avatars. It works with any ImageView and offers a fluent builder plus a color generator.

**amulyakhare/TextDrawable** — GitHub describes it as This light-weight library provides images with letter/text like the Gmail app. It extends the Drawable class thus can be used with existing/custom/network ImageView classes. Also included is a fluent interface for creating drawables and a customizable ColorGenerator.. The repository metadata lists Java as its primary language. The metadata lists the MIT license. This article stays within the project description and details documented in the GitHub repository README.

- Repository: https://github.com/amulyakhare/TextDrawable
- Stars: 3,137 · Forks: 614
- Language: Java
- License: MIT
- Published: 2026-08-13 · Updated: 2026-08-18 · Language: en
- Canonical page: https://hysenlabs.com/projects/amulyakhare-textdrawable

## What Problem It Solves

TextDrawable addresses a narrow but common Android UI need: showing a colored tile with a letter or short text in place of an image. The README explicitly compares it to the Gmail app, which uses such tiles for contacts without photos. The library is for any app that displays user lists, chat threads, or file lists and wants a lightweight, locally generated visual instead of a network image. It targets developers who want to avoid pulling in a full image-loading stack just for avatars. The library extends the Drawable class, so it plugs into standard Android views without custom view classes. This is a focused solution, not a general-purpose rendering engine.

## How It Works: Drawable Subclass and Fluent Builder

The core is a TextDrawable that extends android.graphics.drawable.Drawable. That means it can be assigned directly to an ImageView via setImageDrawable(), or used as a background or compound drawable for TextView and Button. The README shows a fluent interface for construction: TextDrawable.builder() returns a builder, and chained methods like buildRect(), buildRoundRect(), and buildRound() produce the final drawable. A beginConfig() and endConfig() pair allows setting properties like border thickness, text color, font size, typeface, bold, and uppercase conversion. The builder can be stored as an IBuilder instance and reused to create multiple drawables with the same configuration but different text and color. This design separates configuration from per-item data, which is useful for list adapters.

## Getting It Running: Gradle and Basic Usage

The README provides a Gradle snippet that adds a custom Maven repository hosted at Bintray and then declares the dependency: compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'. Note that the repository URL is 'http://dl.bintray.com/amulyakhare/maven'. This is an HTTP URL, not HTTPS, which may cause issues in modern Gradle setups that enforce secure repositories. The basic usage is straightforward: create a TextDrawable with a string and a color, then assign it to an ImageView. For example, TextDrawable.builder().buildRect("A", Color.RED) produces a square red tile with the letter A. The README notes that if the ImageView has fixed width and height, the drawable auto-scales to fit. Alternatively, you can set the drawable's width and height in pixels using .width() and .height() inside the config block, which allows wrap_content ImageViews.

## Shapes, Borders, and Font Control

The library offers three shape builders: buildRect, buildRoundRect, and buildRound. buildRoundRect takes a radius in pixels for rounded corners, while buildRound creates a perfect circle. The border thickness is set in pixels via withBorder(). Font styling is configurable: textColor, useFont(Typeface), fontSize in pixels, bold(), and toUpperCase(). These options give decent control for simple avatars. However, there is no support for gradients, strokes beyond a solid border, or custom shapes. The radius and font size are in pixels, not dp, which means the drawable may not scale consistently across screen densities unless you convert dp to px manually. This is a limitation worth noting for multi-device apps.

## ColorGenerator: Stable Colors for Lists

The library includes a ColorGenerator class with two predefined palettes: MATERIAL and DEFAULT. The getRandomColor() method returns a random color, but the more useful method is getColor(Object key), which returns the same color for the same key. The README explicitly recommends this for list or grid views, where you want each user or item to have a consistent color across scrolls and rebinds. The example uses a string like "user@gmail.com" as the key. This is a simple hash-based approach, though the README does not specify the hash algorithm or whether collisions are handled. For a list with a few dozen items, it works fine. For thousands of items, you might see color collisions, which is acceptable for avatars.

## Limitations and When It Is the Wrong Tool

The biggest limitation is that TextDrawable only generates static, text-on-solid-color tiles. It cannot load network images, cache bitmaps, or handle async loading. If your app already uses an image-loading library like Glide or Picasso, you would not replace it with TextDrawable; you might use TextDrawable as a placeholder or fallback, but the README does not show such integration. Another limitation is the dependency on a deprecated Bintray repository. Bintray was shut down by JFrog in 2021, so the provided repository URL may no longer work. The README does not mention any alternative distribution, and there are no recent releases or pushes recorded. This is a real risk for new projects. Also, the library is Java-only, so Kotlin projects can use it, but there is no Kotlin-specific API or coroutine support.

## Alternatives and Comparison

A common alternative is to use a third-party library like Glide or Coil, which can generate letter avatars via transformations or custom targets. Glide, for example, can load a placeholder drawable, but it does not have built-in letter tile generation; you would need to write a custom transformation. Another alternative is to create a simple VectorDrawable or a custom View that draws text on a canvas. That approach gives you full control over density scaling and styling but requires more code. The key difference is that TextDrawable is a ready-made Drawable subclass with a fluent builder, so you avoid writing canvas code. However, unlike Glide, it has no caching, no memory management, and no network support. If you already use Glide, you might prefer to build a custom Drawable and use it as a placeholder, but that is more work than just using TextDrawable.

## Maintenance and License

The repository is archived? No, the metadata says 'Archived: no', but there are no recent releases and the last push is unknown. The README references Bintray, which is defunct, so the project appears unmaintained. The license is MIT, which permits commercial use, modification, and redistribution with attribution. There is no explicit maintenance documentation, no changelog, and no issue tracker information in the provided material. For a small library like this, the maintenance cost is low because the code is likely small and stable, but the dependency on a dead repository is a serious concern. You may need to download the source and build it locally or use a mirror like JitPack if you want to use it. Given the MIT license, you can also fork and fix the repository URL yourself.

## Conclusion

Adopt TextDrawable if you need a simple, dependency-free way to render letter avatars in an Android app, especially for lists or grids where a stable color per key matters. Avoid it if you need complex shapes, gradients, or asynchronous image loading; those belong in a dedicated image-loading library. Before adopting, verify that the Bintray repository is still reachable and that the 1.0.1 artifact resolves in your build, since the project has not been updated recently and no releases are listed.

## FAQ

### What is a drawable, according to TextDrawable?

It is the base class this library extends. That single decision is why the tile works with existing, custom and network ImageView classes, and why it can also be used as a background drawable or as a compound drawable on a TextView or Button.

### How do I install the TextDrawable library?

The README gives a Gradle snippet that adds a maven repository at http://dl.bintray.com/amulyakhare/maven and a compile dependency on com.amulyakhare:com.amulyakhare.textdrawable:1.0.1. That is the only version named in the repository, which publishes no releases.

### How do I get a stable colour for the same text with TextDrawable?

Use the keyed form of the colour generator: getColor with a string returns the same colour for the same key, which the README notes is useful for list and grid views. getRandomColor returns a colour with no key.

### What can TextDrawable be used with besides ImageView?

It can be combined with LayerDrawable, InsetDrawable, AnimationDrawable and TransitionDrawable, set as a background drawable, or attached as a compound drawable on a TextView or Button. The README also notes that multiple letters or unicode characters can be combined into one tile.

## Sources

- [Official README](https://github.com/amulyakhare/TextDrawable#readme)
- [Project repository](https://github.com/amulyakhare/TextDrawable)
- [README](https://github.com/amulyakhare/TextDrawable/blob/master/README.md)
- [Releases](https://github.com/amulyakhare/TextDrawable/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/amulyakhare-textdrawable
