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
- Custom TextView draws text multiple times with position shifts to create 3D extrude effect
- Handles RTL languages by reversing extrude direction and adjusting padding dynamically
- Preserves all standard TextView attributes like textSize, fontFamily, and letterSpacing
- Uses Android pseudo localization to catch hardcoded strings before real translations arrive
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.
About This Article
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.
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.
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.