Search code examples
androidtextviewlocaleright-to-left

Why doesn't the default text direction for a TextView match the locale?


TL;DR In RTL layouts, should Latin text be mirrored, and if so why doesn't Android do this by default?


I am trying to implement RTL support in my app, and an issue I have run into is that Latin characters by default don't appear on the right side of a TextView or EditText. I would have thought that even if the app was not translated into an RTL language that the behaviour should be to still mirror the text.

Looking into it there is an easy fix by setting android:textDirection="locale" or even android:textAlignment="viewStart" but why isn't this the default to start with? So it makes me wonder whether this is the correct way to approach displaying RTL Latin text or whether it should still match the original script.

This is an image to help illustrate what I am referring to. Here the EditText cursor is over to the right but the English hint still remains over to the left.

RTL issue


Solution

  • First of all, I'm an Iranian and our language is RTL. Actually it totally depends on the design of your application but we usually expect the default behavior in most cases (like the photo you've provided). You can check the screenshots from Alibaba Travels which is the most popular application for buying plane tickets in Iran. When the name of the airports/cities are Farsi, they are aligned to right and vice versa for the English ones.

    Farsi names English names

    But in some contexts like a table showing descriptions of a product that most items are RTL, it would totally make sense to align LTR items to the right. You can take a look at Digikala below (it's the biggest online store in Iran)

    Digikala