Android app的国际化

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zz531987464/article/details/51765399

如何将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>


演示效果



猜你喜欢

转载自blog.csdn.net/zz531987464/article/details/51765399