Android 阿拉伯語適配

首先推薦一個鏈接:https://www.jianshu.com/p/d8cd294a5c31
開始進入正題
1、sdk要求: Android 4.2 即 SDK 17
2、四個重要屬性:
android:layoutDirection
設置組件的佈局排列方向

android:textDirection
設置組件的文字排列方向

android:textAlignment
設置文字的對齊方式

getLayoutDirectionFromLocale()
獲取指定地區的慣用佈局方式
3、配置說明
<application

android:supportsRtl=“true” >


4、變更屬性
AS 支持一鍵適配 RTL,主要是在原來 Layout 中設置 Left 和 Right 屬性的補充添加 Start 和 End 屬性
Refactor > Add RTL Support Where Possible…
5、edittext注意添加屬性

android:textAlignment="viewStart"
android:gravity="start"

或者在style中:

 <item name="android:textAlignment">viewStart</item>
 <item name="android:gravity">start</item>
 <item name="android:textDirection">locale</item>

6、textview加入屬性

 <item name="android:textDirection">locale</item>

7、圖標
一些方向圖標,重新做一個相對方向的放到 mipmap-ldrtl-xxxhdpi 包下
8、預覽
利用在 AS 右邊的預覽佈局工具中的語言切換工具,切換成阿拉伯語,能實時看到佈局的效果圖
9、阿拉伯語代碼:ar
10、複雜佈局:
複雜的模塊,可以放到 layout-ldrtl 包下,單獨做一個佈局來適配阿拉伯語,例如詳情頁

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章