问题
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 View
s not to be mirrored when these locales are set. For example, I don't want my app's View
s 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