官网地址
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 categorizes device screens using two general properties: size and density. You should expect that your app will be installed on devices with screens that range in both size and density. As ...
Android categorizes device screens using two general properties: size and density. You should expect that your app will be installed on devices with screens that range in both size and density. As ...
创建本地语言环境目录和字符串文件 为了支持更多的语言,需要在values目录的名称需要以连字符“—”和国家的ISO码结尾.举个例子,values-es/目录中包含了...Android在运行时会根据设备的语言环境设置来装载适当的资源.
Intel® C++ Software Development Tool Suite 1_0 for Linux OS Supporting Mobile Internet Devices
Manufacturers: Designing Android Devices 19 Mobile Operators: Delivering the Android Experience 20 Apps Drive Device Sales: Developing Android Applications 21 Taking Advantage of All Android Has to ...
libraries supporting the Android platform emerged—everything from game frame- works, like cocos2d-x, to build systems, like Apache Maven. In November 2010 I was asked to review a book from Manning ...
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 ...
But the use of Android and iOS smart devices have created a maintenance nightmare not only for the IT organization but for the IT auditors as well. This book will serve as a guide to IT and Audit ...
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 ...
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 ...
It’s inside millions of cell phones and other mobile devices, making Android a major platform for application developers. That could be your own program running on all those devices. Within minutes...
It's inside millions of cell phones and other mobile devices, making Android a major platform for application developers. That could be your own program running on all those devices. Within minutes,...
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 ...
TGac Channel Model Addendum Supporting Material
Later, it explains how to build an app that takes advantage of the latest Android SDK while still supporting older Android versions. It also demonstrates how the performance of an app can be improved ...
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 profiles: Networking, Dial-up, Fax, LAN access, Headset and WiFi
Initially covering the threats, risks, and vulnerabilities in software and in the Android environment, this book will then dig deeper, exploring different types of authentication methods that can be ...
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 ...