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
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.