2013-10-08 48 views
4

我已閱讀How can I create a multilingual android application?Do android support multiple languages?我知道創建一個多語言的Android應用程序。但我的問題是針對不同的語言顯示從右到左和從左到右的文本。如何爲從右至左的語言創建多語言Android應用程序?

例如英文a TextView作爲標籤應位於EditText和波斯文的左側,TextView應位於EditText的右側。

enter image description here enter image description here

我怎麼能支持從右到我的用戶界面左側的語言和用戶界面?

我應該爲從右到左的語言設計不同的佈局嗎?如何在佈局中爲RTL指定文件夾?像layout-rtl?或者,我如何確定語言是否正確?

有沒有更簡單的方法?

+0

希望這可以幫助您http://developer.android.com/guide/topics/resources/providing-resources.html#BestMatch並減緩此http://developer.android.com/guide/topics/resources/ localization.html –

回答

5

官方支持在Android 4.2中引入,請參閱RTL Layout Support。您可以通過enter link description here查詢是否正在使用它。

您可以嘗試在所有情況下使用相同的佈局,也可以在'layout-ldrtl'中指定特定佈局。

根據您的示例,如果您使用的是RelativeLayout,則需要使用android:layout_alignParentStart屬性,而不是android:layout_alignParentLeft將標籤從左向右自動移動。

+2

確保您還在清單中的應用程序標籤內添加了android:supportsRtl =「true」。 – Ashwini

0

您可以創建一個不可翻譯的單詞列表,以便您知道調用這些資源時它將始終使用相同的語言。 例如:

<string name="english">English</string> 
<string name="english_fixed" translatable="false">English </string> 

在這種情況下,參考到R.string.english_fixed將始終顯示相同的字符串,同時將R.string.english翻譯的單詞。 然後,您可以在兩個不同的TextView中使用左側和右側的兩個不同資源。

我理解這個問題嗎?