1

I have an app that supports Hebrew and declares in the manifest its support for RTL locales. However, there are other RTL locales that I do not support and would like my Views not to be mirrored when these locales are set. For example, I don't want my app's Views to be swapped from right to left when in the Arabic locale, since I don't support Arabic and therefore text will show in English.

2 Answers 2

5

I guess the best way is to make android:supportsRtl value to be selected according to the language. To do that see below:

AndroidManifest.xml

 <application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
    android:supportsRtl="@string/is_hebrew" >...</application>

Then in values/strings.xml add:

<string name="is_hebrew">false</string>

And with values-he/strings.xml add:

<string name="is_hebrew">true</string>
6
  • 1
    This is pretty clever, but does not work to perfection. Apparently the system reads the manifest file only once, either when the app is installed, or first run. This means that if you install the app while the phone is in English, run it and then change the phone's language to Hebrew, the app will be stuck with the left-to-right layout. You would have to reinstall the app with the phone in Hebrew in order to have it change to the right-to-left layout.
    – user692168
    Mar 21, 2014 at 19:19
  • Have you killed the app after changing the language? I've did a testing version and it worked for me very well. see here: dl.dropboxusercontent.com/u/4172185/testStackoverflow.tar.gz
    – xsoh
    Mar 21, 2014 at 22:42
  • Can you put that in a zip file? I'm on Windows and don't have privileges to install software to open that file. And yes, I killed the app, but still will not change until you uninstall the whole thing.
    – user692168
    Mar 21, 2014 at 22:47
  • Here(Note: I did the same idea but with Arabic language): dl.dropboxusercontent.com/u/4172185/testStackoverflow.zip
    – xsoh
    Mar 21, 2014 at 22:53
  • 1
    I guess there is a problem with the older versions of the platform. I've tried it on Kitkat (4.4.2) and it was working very well. But on JB(API 18) didn't work. Note: I'm changing the language thought Settings not Custom Locale.
    – xsoh
    Mar 22, 2014 at 8:57
2

You can choose to turn mirroring on or off at runtime. See https://stackoverflow.com/a/17683045/192373. This is limited to 4.2 or higher, and only in onCreate() of your activity.

1
  • Used in combination with @xsoh 's suggestion I may add.
    – user692168
    Mar 24, 2014 at 23:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.