关于安卓屏幕适配的个人风险
2014-10-31 11:05
330 查看
src : http://developer.android.com/training/basics/supporting-devices/screens.html
查看官方给的建议,就是我们的图片是需要有一个比例的。比例如下
xhdpi: 2.0
hdpi: 1.5
mdpi: 1.0 (baseline)
ldpi: 0.75
例如我们放了一张200x200 的图片在drawable- xhdpi文件加下,那么为了兼容,相应的我们需要放150x150
在 hdpi, 100x100 的在 mdpi, 和 75x75 在 ldpi 文件夹下!但 Low-density
(ldpi)文件不一定是必须的,因为当你提供了Hdpi文件的时候。系统会自动的缩小一半来适配LDPI的屏幕。碉堡了,所以我们平时在反编译辨认的apk时候会看到,其实很多文件是放在Hdpi目录下,大概就是这个道理啦
resources
aren’t always necessary. When you provide hdpi assets, the system scales them down by one half to properly fit ldpi screens.
--------
当然我们适配的时候,还是需要考虑文件的命名的规范,下面是谷歌官方给出的一些建议
学安卓的都看得懂,就不翻译了!
Try to name files so that related assets will group together inside a directory when they are sorted alphabetically. In
particular, it helps to use a common prefix for each icon type. For example:
Asset Type | Prefix | Example |
---|---|---|
Icons | ic_ | ic_star.png |
Launcher icons | ic_launcher | ic_launcher_calendar.png |
Menu icons and Action Bar icons | ic_menu | ic_menu_archive.png |
Status bar icons | ic_stat_notify | ic_stat_notify_msg.png |
Tab icons | ic_tab | ic_tab_recent.png |
Dialog icons | ic_dialog | ic_dialog_info.png |
Create Different Bitmaps
You should always provide bitmap resources that are properly scaled to each of the generalized density buckets: low, medium, high and extra-high density. This helps you achieve good graphical quality and performance on all screen densities.
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
This means that if you generate a 200x200 image for xhdpi devices, you should generate the same resource in 150x150 for hdpi, 100x100 for mdpi, and 75x75 for ldpi devices.
Then, place the files in the appropriate drawable resource directory:
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.
---------------
相关文章推荐
- 关于屏幕适配问题的工作<个人记录>
- 关于安卓屏幕适配,drawable的适配和图片适配问题
- 关于安卓3.0以上的系统屏幕适配问题的一些心得
- 关于android 开发屏幕适配的个人见解
- 关于安卓的屏幕适配 (待完善)
- 关于安卓3.0以上的系统屏幕适配问题的一些心得
- 关于安卓屏幕适配
- 关于Cocos2dx屏幕适配
- 关于Android的多种屏幕适配
- 安卓多屏幕适配[转]
- 关于android屏幕适配问题
- Android-关于屏幕适配的一些经验
- Android,关于设备独立像素(dip/dp),关于机型屏幕适配
- 关于android分辨率兼容(屏幕适配)问题
- 屏幕适配的一些个人经验
- 关于Android中涉及屏幕适配的单位dp,px,sp,dip的学习笔记。
- 关于web页自动适配屏幕大小
- iOS设备的硬件适配 (关于armv6, armv7, armv7s 个人觉得说得比较清楚)
- 【Android 适配】关于android屏幕适配的最佳实践
- 关于win8的屏幕适配