android-Supporting Different Devices
2015-12-27 21:16
489 查看
Some of the important variations that you should consider include different languages, screen sizes, and versions of the Android platform.
> Supporting
Different Languages
Learn how to support multiple languages with alternative string resources.
Supporting Different Screens
Learn how to optimize the user experience for different screen sizes and densities.
Supporting Different Platform Versions
Learn how to use APIs available in new versions of Android while continuing to support older versions of Android.
>To add support for more
languages, create additional
inside
>Android categorizes device screens using two general properties: size and density. (Different
Screens)
As such, you should include some alternative resources that optimize your app’s appearance for different screen sizes and densities.
There are four generalized sizes: small, normal, large, xlarge
And four generalized densities: low (ldpi), medium (mdpi), high (hdpi), extra high (xhdpi)
To optimize your user experience on different screen sizes, you should create a unique layout XML file for each screen size you want to support.
Note: Android 3.2 and above supports an advanced method of defining screen sizes that allows you
to specify resources for screen sizes based on the minimum width and height in terms of density-independent pixels.
To generate these images, you should start with your raw resource in vector format and generate the images for each density using the following size scale:
xhdpi: 2.0
hdpi: 1.5
mdpi: 1.0 (baseline)
ldpi: 0.75
>how to take advantage of the latest APIs while continuing to support older versions as well.(Platform
Versions)
Tip: In order
to provide the best features and functionality across several Android versions, you should use the Android
Support Library in your app, which allows you to use several recent platform APIs on older versions.
> Supporting
Different Languages
Learn how to support multiple languages with alternative string resources.
Supporting Different Screens
Learn how to optimize the user experience for different screen sizes and densities.
Supporting Different Platform Versions
Learn how to use APIs available in new versions of Android while continuing to support older versions of Android.
>To add support for more
languages, create additional
valuesdirectories
inside
res/that include a hyphen and the ISO language code at the end of the directory name.
MyProject/ res/ values/ strings.xml values-es/ strings.xml values-fr/ strings.xml
>Android categorizes device screens using two general properties: size and density. (Different
Screens)
As such, you should include some alternative resources that optimize your app’s appearance for different screen sizes and densities.
There are four generalized sizes: small, normal, large, xlarge
And four generalized densities: low (ldpi), medium (mdpi), high (hdpi), extra high (xhdpi)
To optimize your user experience on different screen sizes, you should create a unique layout XML file for each screen size you want to support.
MyProject/ res/ layout/ # default (portrait) main.xml layout-land/ # landscape main.xml layout-large/ # large (portrait) main.xml layout-large-land/ # large landscape main.xml
Note: Android 3.2 and above supports an advanced method of defining screen sizes that allows you
to specify resources for screen sizes based on the minimum width and height in terms of density-independent pixels.
To generate these images, you should start with your raw resource in vector format and generate the images for each density using the following size scale:
xhdpi: 2.0
hdpi: 1.5
mdpi: 1.0 (baseline)
ldpi: 0.75
MyProject/ res/ drawable-xhdpi/ awesomeimage.png drawable-hdpi/ awesomeimage.png drawable-mdpi/ awesomeimage.png drawable-ldpi/ awesomeimage.png
>how to take advantage of the latest APIs while continuing to support older versions as well.(Platform
Versions)
Tip: In order
to provide the best features and functionality across several Android versions, you should use the Android
Support Library in your app, which allows you to use several recent platform APIs on older versions.
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15" />
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); } }
<activity android:theme="@android:style/Theme.Dialog">
<application android:theme="@style/CustomTheme">
相关文章推荐
- android中的syle和theme
- Android Hook神器:XPosed入门与登陆劫持演示
- Android数据库SQLite
- android项目结构说明
- Git服务器的搭建, 以及Android studio 上克隆git 服务器上的项目
- 《Android开发艺术探索》读书笔记--part1 Activity的生命周期和启动模式
- android studio 中文社区
- Android listview与adapter用法
- Android四大组件之:BroadcastReceiver
- 案例一 android中获取SD卡的剩余容量
- Android插件化(二):使用DexClassLoader动态加载assets中的apk
- 『Android Studio』使用Gradle打包、签名
- 获取Android设备的唯一识别码
- startActivityForResult无法调用singleTask的Activity返回的数据
- Ubuntu 14.04.2 移植FFmpeg 2.8.3 到Android平台
- Android Tag-start Training
- Windows下搭建Android NDK开发环境及命令行编译
- Android设计模式之一个例子让你彻底明白装饰者模式(Decorator Pattern)
- Android内核学习笔记
- Android应用打开另一个应用程序