官网地址
http://developer.android.com/training/basics/supporting-devices/index.html
一、支持不同的语言
和其它程序一样,通常为了支持多种语言,需要额外写一份资源文件。
新建一个和values目录同级的values-zh的文件夹,将里面strings的值都写成中文
比如,原来是这样
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">MyFirstApp</string> <string name="action_settings">Settings</string> <string name="hello_world">Hello world!</string> <string name="edit_message">Entry a message</string> <string name="button_send">Send</string> <string name="title_activity_display_message">DisplayMessageActivity</string> <string name="action_search">Search</string> </resources>
修改后成这样
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">我的应用</string> <string name="action_settings">设置</string> <string name="hello_world">你好,世界</string> <string name="edit_message">输入一个消息</string> <string name="button_send">发送</string> <string name="title_activity_display_message">显示消息</string> <string name="action_search">查询</string> </resources>
图片国际化,类似。
二、支持不同的屏幕分辨率
为了支持不同屏幕的分辨率,首先要创建不同的layout ,和资源文件差不多,也是在相同目录下新建不同的文件夹,如layout ,layout-large,layout-land ....
然后创建不同的位图资源,其实在创建项目的时候Eclipse已经为我们创建了,如
drawable-hdpi,drawable-ldpi,drawable-mdpi ....
三、支持不同平台
1. SDK
在创建项目的时候就有最小支持SDK版本,和目标SDK版本,项目创建好后在清单文件AndroidManifest.xml中<uses-sdk>里有相应的设置
2.在运行时检查系统版本
private void setUpActionBar() { // Make sure we're running on Honeycomb or higher to use ActionBar APIs if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); } }
3. 使用样式和主题
//To make your activity look like a dialog box: <activity android:theme="@android:style/Theme.Dialog"> //To make your activity have a transparent background: <activity android:theme="@android:style/Theme.Translucent"> //To apply your own custom theme defined in /res/values/styles.xml: <activity android:theme="@style/CustomTheme"> //To apply a theme to your entire app (all activities), add the android:theme //attribute to the <application> element: <application android:theme="@style/CustomTheme">
很简单吧
相关推荐
多语言支持是Android应用开发中的一个重要方面,它允许应用根据不同国家和地区的语言环境提供相应的本地化资源。这不仅包括文本内容的翻译,还可能涉及日期、数字格式以及资源文件(如图片和声音)的本地化。为了...
The CDD ensures that these APIs are stable and predictable, allowing developers to write applications that work consistently across different devices and versions of Android. ##### 3.2 Soft API ...
"Supporting Different Devices" 是Android开发中的核心概念,它涉及到多语言支持、屏幕适配策略以及资源的优化。 **一、多语言支持** 为了让应用能够触及全球用户,开发者需要实现多语言支持。Android通过资源...
–Mobile Support – Support for building to mobile devices using the Touch Gestures (PC/Mac, Android and iOS Supported) –Unity2D Compatible– Select a Movement Component Type to build in 3D or 2D ...
Don抰 spend time testing on different devices and browsers. Use a reliable, CSS compliant JavaScript library based jQuery, ...