Android RTL locales. How to mirror only when locale is supported?

时光总嘲笑我的痴心妄想 提交于 2019-12-08 07:06:51

问题


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.


回答1:


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.




回答2:


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>


来源:https://stackoverflow.com/questions/22518862/android-rtl-locales-how-to-mirror-only-when-locale-is-supported

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!