官网地址
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">
很简单吧
相关推荐
这两个属性确保了应用能够运行在指定的系统版本之上,并能充分利用这些版本中的API。 在运行时,开发者还可以利用Build.VERSION类中的常量来检测当前系统的版本,并根据版本来决定是否使用某些API。如果当前系统的...
多语言支持是Android应用开发中的一个重要方面,它允许应用根据不同国家和地区的语言环境提供相应的本地化资源。这不仅包括文本内容的翻译,还可能涉及日期、数字格式以及资源文件(如图片和声音)的本地化。为了...
Intel® C++ Software Development Tool Suite 1_0 for Linux OS Supporting Mobile Internet Devices
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 ...
This library provides a highly configurable logging framework for Android apps, supporting multiple log destinations simultaneously: files SQLite databases logcat sockets syslog email Runs on ...
They not only show you how to use the sensor related APIs effectively, they also describe how to use supporting Android OS components to build complete systems. Along the way, they provide solutions ...
Android Text Samples These samples show how to work with text in Android. Explore the samples The TextStyling Java and Kotlin samples show how to style text using spans. The RoundedBackground sample ...
The Android platform gives developers a fair bit of control while still supporting a familiar programming language. However, the frameworks, GUI widgets, and development model is different than any ...
Also, it shows you how to build an app that runs on an Android wear device., Later, it explains how to build an app that takes advantage of the latest Android SDK while still supporting older Android ...
标题:“Supporting_SCCM_2007_Workbook”(支持SCCM 2007工作手册)指向了微软System Center Configuration Manager(SCCM)2007版本的一份详尽培训资料。这份工作手册是微软为内部培训目的而专门准备的,涵盖了...
- **Hinton**:Geoffrey Everest Hinton,加拿大计算机科学家,深度学习领域的先驱之一,以其在神经网络和机器学习方面的贡献而闻名。 #### 内容解读与扩展知识点: 1. **预训练(pre-training)** - 预训练是训练...
文档“TGac Channel Model Addendum Supporting Material”(IEEE802.11-09/0569r0)提供了对TGn信道模型补充文档的支持材料。此文档主要为Very High Throughput Task Group (TGac)的信道模型提供必要的背景资料。 ...
You can now chill out on supporting multiple languages on your android application. It is normal for your Android application to support multiple languages. And it is very easy because you can do them...
(Currently supporting devices upto api 9 ) Material Preference Library uses com.android.support:preference-v7:x.x.x support library widgets. Also it includes a color chooser dialog widget, that can ...