您的位置:首页 > 移动开发

Android app的国际化

2016-06-27 00:19 435 查看
如何将anroid app应用国际化?这个其实只需要我们在res/目录下存放不同国家的资源文件,系统就会根据设置的语言不同找到相应res文件夹下的国家资源文件!下面我来写一个简单的实例来演示如何将一个android app实例化。

app资源文件布局





如上图所示,我们需要创建需要订制化的那些国家的相关的资源文件夹,drawable文件夹里面现在存放的是文件名相同的国家国旗logo.bmp, values文件夹里面存放的是不同国家语言的文字信息等的string.xml文件。其实文件名都是相同的,不同的是文件夹名,一个国家对应着一个资源文件夹!
values文件夹里面的不同string.xml文件







app的xml文件

<TextView
android:layout_gravity="center_horizontal"
style="@style/textStyle"
android:text="@string/hello_world" />
<TextView
android:layout_gravity="center_horizontal"
style="@style/textStyle_content"
android:text="@string/hello_world" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo">
</ImageView>

app的style.xml文件
<style name="textStyle">
<item name="android:textColor">#ff0000</item>
<item name="android:textSize">15sp</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
</style>
<style name="textStyle_content" parent="textStyle">
<item name="android:textColor">#0ff000</item>
</style>

演示效果







内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android app 国际化 语言