软件国际化
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/name"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/exit"
/>
</LinearLayout>
在 values或者values-en或者values-en-rUS或者values-zh 目录下分别建立strings.xml 设置手机的语音为简体中文就加载中文模式 实现文字国际化
在 drawable-zh或者drawable-en 目录下分别放同名文件则 实现突破国际化
屏幕适配
分别在layout-320x240 与layout-480x320文件夹下建立main.xml文件,找不到的时候直接layout文件夹下
样式与主题
在values下新建style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- 样式 只是用于组件-->
<style name="textViewStyle">
<item name="android:textSize">22sp</item>
<item name="android:textColor">#FF0000</item>
</style>
<style name="childStyle" parent="textViewStyle">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#00FF00</item>
</style>
<style name="childStyle.liming">
<item name="android:textColor">#0000FF</item>
</style>
<!-- 用于整个activity-->
<style name="itcastTheme">
<item name="android:windowNoTitle">true</item> <!-- 没有标题-->
<item name="android:windowFullscreen">?android:windowNoTitle</item> <!-- 全屏且与标题显示一致-->
<item name="android:textSize">18sp</item> <!-- 窗口中字体大小 如果与样式中冲突 样式优先-->
<item name="android:textColor">#FFFFFF</item>
</style>
</resources>
设置<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cn.itcast.style"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name"
>
<activity android:name=".MainActivity"
android:label="@string/app_name" android:theme="@style/itcastTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="8" />
</manifest>