Android的确定设备在从右到左的语言/布局 [英] android determine if device is in right to left language/layout
问题描述
有没有一种方法,以确定该设备中,而不是一些左的语言(像阿拉伯语)一个正确的的左到右(英文)?
Is there a way to determine if the device is in a right to left language (something like Arabic) as opposed to something that's left to right (English)?
东西与旧的API级别(低至10)兼容是必要的。
Something compatible with older API levels (down to 10) is necessary
SOLUTION
我最终使用在接受的答案的XML方法。更远的路线,我还添加此处指示为实例code,其中我没有获得getResources()
i ended up using the xml method in the accepted answer. Farther down the line, i also added the code indicated here for instances where I didn't have access to getResources()
<一个href=\"http://stackoverflow.com/questions/18996183/identifyng-rtl-language-in-android/23203698#23203698\">Identifyng在Android的RTL语言
推荐答案
您可以创建一个价值观ldrtl 有一个名为xml文件夹isrighttoleft.xml:
You could create a values-ldrtl folder with a xml file called isrighttoleft.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="is_right_to_left">true</bool>
</resources>
和在值与文件夹相同的文件:
and in your values folder the same file with:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="is_right_to_left">false</bool>
</resources>
终于在code:
And finally in Code:
boolean isRightToLeft = getResources().getBoolean(R.bool.is_right_to_left);
的值-ldrtl将只有在特定的设置(例如,语言)是从右至左读取的语言的设备上使用。
The values-ldrtl will only be used on a device where the specific settings (e. g. Language) are right-to-left-read languages.
这篇关于Android的确定设备在从右到左的语言/布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!