Designing for Dual-Script Navigation in Alif2Ayah
A technical breakdown of synchronizing RTL Arabic and LTR English scripts in a mobile interface while maintaining readability and performance.
Building a script-intensive app like Alif2Ayah presents a unique spatial challenge: the collision of two opposing reading directions. In a standard mobile interface, users expect a linear flow. However, when displaying Quranic Arabic (Right-to-Left or RTL) alongside an English translation (Left-to-Right or LTR), the interface must accommodate two different visual anchors. If the layout is not handled with architectural precision, the reader’s eye is forced to zigzag across the screen, leading to cognitive fatigue. Our goal during the development of Alif2Ayah was to create a "Side-by-Side" rendering system that keeps both scripts perfectly synchronized, ensuring that as you scroll, the related verse and translation never drift apart.
The Anchor Point Dilemma
In LTR languages, the eye anchors on the left margin. In RTL languages, the anchor is the right. When you place these side-by-side in a narrow mobile viewport, you immediately lose about 40% of your horizontal real estate to padding and gutter requirements. We initially experimented with a stacked approach—Arabic on top, English below—but found this disrupted the "glanceability" required for learners. A learner needs to see the specific Arabic word and its corresponding translation in the same horizontal plane to form a mental map.
To solve this, we moved to a dual-column flex layout. However, this introduced a synchronization problem. Arabic script is often taller due to diacritics (harakat) and requires larger font sizes to remain legible compared to Latin characters. If Verse 1 of the Arabic text is three lines long, but the English translation is only one line, Verse 2 must still align its top edge across both columns. Without strict row-level synchronization, the further you scroll, the more the two translations become decoupled from their source text.
Implementing Row-Based Synchronization
In Jetpack Compose, the natural inclination is to use two separate LazyColumn components side-by-side. This is a mistake. Scrolling two independent lists while trying to maintain scroll-position parity is a recipe for performance lag and jank. Instead, we treated each verse pair as a single high-level Item within a single LazyColumn.
Each item is a Row containing two Box or Column wrappers. This ensures that the height of the row is determined by whichever script is longer. If the English translation for a particularly complex verse runs into a second paragraph, the Arabic side expands its container to match, maintaining the white space and the clear horizontal break before the next verse begins.
| Feature | Stacked Layout (Vertical) | Side-by-Side (Dual-Column) |
|---|---|---|
| Reading Flow | Sequential (Stop-and-start) | Comparative (Simultaneous) |
| Space Efficiency | High (Full width for both) | Low (Split width) |
| Eye Strain | Low (Linear) | Moderate (Scanning) |
| Context Retention | Moderate | High |
For Alif2Ayah, context retention was the priority. We mitigated the "Low Space" drawback by allowing users to toggle the font sizes independently, a design principle we also touched upon in our guide on Designing for High-Density Scripts.
Handling Script-Specific Typography
One of the most common errors in dual-script UI is applying a global line-height. Arabic script requires significantly more vertical breathing room than English. If you apply a standard 1.2x line-height to a row, the English will look fine, but the Arabic diacritics will overlap with the line above.
We implemented a "Baseline Offset" strategy. In our TextStyles, we defined specific PlatformTextStyle configurations for the Arabic font (typically Uthmani or Indopak) that include includeFontPadding = true. For the LTR translation, we set this to false. This allows the English text to sit higher in its container, visually balancing against the descending strokes of the Arabic script.
The Problem of Punctuation and Mirrored UI
Android’s native RTL support often automatically mirrors the entire UI. While this is helpful for a purely Arabic app like Salah Companion, it creates chaos in a dual-script environment. If the system mirrors the entire screen, your LTR translation might suddenly align to the right, reversing the meaning of periods and parentheses.
In Alif2Ayah, we explicitly wrap the translation component in a CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr). This forces the English text to stay LTR even if the user’s entire device is set to an Arabic locale. This "Local Directionality Override" is crucial for maintaining the integrity of the dual-script view. It prevents the "parentheses flip"—where a bracketed note in the English text appears backwards because the system thinks it should be RTL.
Performance Optimization for Long Lists
Rendering two different fonts, one of which is a complex, ligature-heavy Arabic typeface, is computationally expensive. When the user scrolls through a long Surah, the frame rate can drop if the UI is constantly re-measuring these dual-script rows.
We implemented three specific optimizations:
- 1.Text Layout Caching: We pre-compute the text layout for the visible verses and the next three upcoming verses. This prevents the UI thread from hanging during the initial measurement phase of a new row.
- 2.Fixed Width Constraints: By giving the Arabic and English columns fixed percentage widths (e.g., 45% and 55%), we avoid the "double-pass" measurement where Compose tries to figure out how much space each script needs relative to the other.
- 3.Static Image Fallbacks for Complex Script: In very specific instances where a device struggles with complex ligatures, we have the architectural capacity to swap a text block for a pre-rendered vector path, though we prefer live text for accessibility reasons.
Checklist for Dual-Script Mobile UI
When building your own implementation, use this checklist to ensure the two scripts play nicely together:
- [ ] Force Directionality: Is the LTR column explicitly wrapped to prevent mirroring on RTL devices?
- [ ] Synchronized Heights: Are the two scripts part of the same parent Row to ensure their containers share the same vertical bounds?
- [ ] Font-Specific Line Height: Does the Arabic script have at least 1.5x the line-height of the English script to prevent harakat clipping?
- [ ] Visual Gutter: Is there a minimum 16dp gutter between the two scripts to prevent the eye from bleeding across columns?
- [ ] Balanced Weight: Does the Arabic font appear visually equivalent in weight to the English font? (Often, a "Regular" Arabic weight looks thinner than a "Regular" Latin weight; you may need to bump the Arabic to "Medium").
The Importance of the Center Anchor
In our testing, we found that users didn't just look at the left or right; they used the "gutter" (the space between the scripts) as a vertical guide. By keeping this gutter perfectly straight and consistent, we provide a visual rail that the user’s eye follows. If one verse is slightly taller and pushes the next verse down, but the gutter remains consistent, the user doesn't feel lost. This is a subtle UX win that separates a professional productivity tool from a simple text viewer.
We also applied similar logic when Designing for Global Orientation in our other apps, where visual anchors must remain stable regardless of the user's physical or digital direction. In Alif2Ayah, the direction is the script; the stability is the row synchronization.
Conclusion
Designing for dual-script navigation is not just about translation; it is about spatial management. By moving away from independent scrolling lists and embracing a unified, row-synchronized architecture, we ensure that the relationship between the original text and its meaning is never lost to a layout shift. Whether you are building a language learning app or a multi-lingual reference tool, the priority must always be the horizontal alignment of ideas.
What to do next
- 1.Audit your containers: If you are using two separate columns for dual-language content, refactor them into a single list of rows to ensure vertical synchronization.
- 2.Test on RTL devices: Enable "Force RTL layout direction" in Android Developer Options to see if your LTR text incorrectly mirrors or flips its punctuation.
- 3.Adjust Line Heights: Compare your scripts side-by-side and increase the line-height for the more complex script until no characters overlap their neighbors.