1. 支持不同的语言
MyProject/
res/
values/
strings.xml
values-es/
strings.xml
values-fr/
strings.xml
默认values文件夹中存放的是locale。用-加上ISO country code : http://www.isocountrycode.com/
http://blog.chinaunix.net/uid-23933445-id-99701.html
android系统会在app运行时自动加载相应的资源。
2. 支持不同的屏幕大小,以及屏幕方向
- There are four generalized sizes: small, normal, large, xlarge
- And four generalized densities: low (ldpi), medium (mdpi), high (hdpi), extra high (xhdpi)
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
对于不同的density,提供不同的图片会获得较好的图像质量。
density:
- 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
Any time you reference @drawable/awesomeimage, the system selects the appropriate bitmap based on the screen's density.
Note: Low-density (ldpi) resources aren’t always necessary. When you provide hdpi assets, the system scales them down by one half to properly fit ldpi screens.
ldpi 资源并不是必须的,当我们提供hdpi资源时,系统会自动压缩来适合ldpi屏幕。
本文探讨了Android应用如何支持多种语言及不同屏幕尺寸与方向的开发策略,包括资源文件组织、不同密度图片提供以及系统自动适配的技术细节。

被折叠的 条评论
为什么被折叠?



