Android的国际化
来源:互联网 发布:被掩埋的巨人 知乎 编辑:程序博客网 时间:2024/05/23 18:25
由于公司的项目是投放 google play store , 所以要做国际化。国际化遇到的两个大问题
- 字符串国际化
- 布局样式国际化
一:字符串国际化
解决这个问题很简单,在res目录下放不同国家的value文件夹,在相应文件夹里的 strings.xml 文件放对应的语言即可。比如
二:布局样式国际化
中国人的阅读习惯是从左往右阅读、阿拉伯国家的阅读习惯是从右往左读。所以同一个布局在不同的语言环境下,显示的样式是不一样的。比如:
默认情况下的布局
阿拉伯语言情况下的布局
例子中的布局很简单,左边是一个文本,文本的后面有一张图片。
可以看到在阿拉伯语言环境下的页面布局,文本跑到了屏幕的右侧,而图片却不见了。(前面已经说过阿拉伯国家的阅读习惯是从右往左的)
解决方案:
- 方案一:建立多个layout 文件夹,从新布局
- 方案二:Android 4.2系统之后,Google在Android中引入了RTL布局
对于方案一,这个方法比较老了,而且几乎要把所有的布局重写一遍,所以推荐使用第二种方法。在Android 4.2系统之后,Google在Android中引入了RTL布局,更好了支持了由右到左文字布局的显示,为了更好的兼容RTL布局,google推荐使用MarginStart和MarginEnd来替代MarginLeft和MarginRight,这样应用可以在正常的屏幕和由右到左显示文字的屏幕上都保持一致的用户体验。
主要的属性有
1
2
3
4
5
6
android:layout_marginStart
android:layout_marginEnd
android:paddingStart
android:paddingEnd
android:layout_toStartOf
android:layout_toEndOf
用RTL写的布局为:
注意:
在使用的时候RTL布局的时候,AndroidManifest.xml 中添加RTL的支持
1
2
3
4
5
6
7
8
<application
android:name=
"com.yiba.sharewe.application.APP"
android:allowBackup=
"true"
android:hardwareAccelerated=
"false"
android:icon=
"@mipmap/ic_launcher"
android:label=
"@string/app_name"
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
>
0 0
- 【国际化】Android包的国际化
- Android的国际化
- Android的国际化
- Android的国际化
- Android Studio的国际化
- Android app的国际化
- Android Studio的国际化
- Android的国际化
- android的国际化
- android的国际化和本地化
- Android的国际化与本地化!
- android的国际化及本地化
- Android的国际化与本地化
- android的国际化和本地化
- Android的国际化与本地化
- Android的国际化与本地化
- android语言国际化的实现
- Android代码资源的国际化
- 前端小白进阶Day2-HTML写一首诗并配图
- sql 双色球、游标生成以字段为名的表、职工信息
- # 0day漏洞_ETERNALBLUE_windows7X64
- vb.net 教程 5-13 图像处理之像素处理 4
- PHP PDO操作mysql事务
- Android的国际化
- 关于逆波兰算法进行公式单位的推导
- 部署maven
- cached in the local repository, resolution will not be reattempted until the update interval of RIIL
- 浅析自定位
- myeclipse 项目导入eclispe 的注意事项
- JTabbedPane
- 题目1083:特殊乘法
- 2017.4.16重