OkCupid Anton Begeima Aug 28, 2020

Improved Localization with Custom TextView Effects

Article Summary

Anton Begeima from OkCupid's engineering team turned a localization nightmare into an elegant solution. Instead of managing separate images for every language, his team built a custom TextView that handles text effects programmatically.

OkCupid faced a common internationalization challenge: text with visual effects (like extrude/3D styling) was baked into images, making translation impossible. Custom fonts failed because they don't support all character sets across languages. The solution? A custom Android TextView that draws the effect dynamically.

Key Takeaways

Critical Insight

By overriding onDraw() and manipulating the canvas, OkCupid replaced static images with a reusable component that works across all languages while maintaining full design control.

The article includes the complete implementation with custom attributes for extrude depth, color, and stroke width that you can drop into any Android project.

About This Article

Problem

OkCupid needed to remove hardcoded strings for their internationalization project. Text that was baked into images with visual effects became a problem when custom fonts couldn't handle character sets from different languages, especially Asian alphabets.

Solution

Anton Begeima's team built ExtrudeEffectText by extending AppCompatTextView and overriding onDraw(). The code loops through extrudeDepth iterations and translates the canvas position using dx and dy values to render the 3D effect programmatically.

Impact

The custom TextView removed the need for language-specific image assets. Teams could still control colors, extrude direction, and depth without losing standard TextView attributes. This made localization work across RTL and LTR languages without extra complications.