Android在多屏幕、多设备上的适配.pdf
《Android在多屏幕、多设备上的适配.pdf》由会员分享,可在线阅读,更多相关《Android在多屏幕、多设备上的适配.pdf(74页珍藏版)》请在三一文库上搜索。
1、 Supporting Multiple Screens in Android Android多屏幕适配 Preface Author: Ren Fei. Android developer Buding Mobile / Innovation Works Announcement: 本slide内容全部来自互联网,以及我自己的一点臆想,如 有错误,欢迎随便指出。 Origin of the problem 问题的由来 Fragmentation 上千种android设备。 不同的平台版本。 不同的屏幕尺寸、分辨率。 不同的输入方式。 Platform version From v1.5 to
2、 v4.1. 8 main version. 14 sub version. Screen sizes 2.6“ HTC G16 3.2“ 3.7“ HTC G5/G7 4.0“ 4.3“ Samsung i9000/9100 7.0“ 7.7“ 8.9“ Samsung Galaxy Tab 10.1“ Moto Xoom Screen Resolution iPhone iPhone 320*480 640*960 iPad 1024*768 2048*1536 Screen Resolution Android QVGA 240*320 WQVGA 240*400 HVGA 320*48
3、0 WVGA 480*800 FWVGA 480*854 SVGA 600*800 DVGA 960*640 WSVGA 1024*600 WXGA 1280*768 qHD 540*960 HD 1280*720 Screen RES. iPhone vs. Android Android System Support Android系统支持 What does android do ? Some definition Screen resolution 480*800 Screen size 3.7“ Screen density 252dpi DPI(dots per inch), xd
4、pi, ydpi DPI= RES. / SIZE DIP (Density-independent pixel) px = dp * (dpi / 160) Generalized SIZE/DPI G.DPI: hdpi/mdpi/ldpi/xhdpi G.SIZE: small/normal/large/xlarge Generalized DPI definition G.DPIG.DPI DPIDPI 1 DP = ? 1 DP = ? pxpx ldpi (Low density) 120 dpi 0.75 mdpi (Medium density) 160 dpi 1 hdpi
5、(High density) 240 dpi 1.5 xhdpi(Extra-high density) 320 dpi 2 Generalized SIZE definition Android does not currently support screens smaller than small screens. G.SIZEG.SIZE Qualifier(at least)Qualifier(at least) xlarge 960dp x 720dp large 640dp x 480dp normal 470dp x 320dp small 426dp x 320dp Rela
6、tionships RES. + SIZE DPI DPI = RES. / SIZE DPI G.DPI ? SIZE G.SIZE ? Some model devicedevice SIZESIZE G.SIZEG.SIZE DPIDPI G.DPIG.DPI RES. RES. pxpx RES. RES. dpdp HTC wildfire 2.8 in small 140dpi ldpi 240*320 320*428dp HTC hero 3.2 in normal 180dpi mdpi 320*480 320*480dp HTC desire 3.7 in normal 25
7、2dpi hdpi 480*800 320*533dp Dell Streak 5.0 in large 186dp mdpi 480*800 480*800dp HTC sensation 4.3 in normal 256dpi hdpi 540*960 360*640dp Galaxy note 5.3 in normal 280dpi xhdpi 800*1280 400*640dp HTC Flyer 7.0 in large 170dpi mdpi 600*1024 600*1024dp Galaxy tab 7.0 in normal 170dpi hdpi 600*1024 4
8、00*682dp Xoom 10.1 in xlarge 150dpi mdpi 800*1280 800*1280dp DPI G.DPI G.DPI 大部分等于真实DPI最临近的G.DPI。 如果DPI正好在两个G.DPI正中间怎么办? G.DPI可能和DPI相差很多。 Samsung galaxy tab G.DPI是由手机厂商定义的。 选择标准是使新的设备能最好的适用于现有app。 SIZE G.SIZE SIZE 和 G.SIZE 并没有很明显的关系。 G.SIZE是由RES.(dp) 定义的。 参考G.SIZE的下界限定。 RES.(px) + G.DPI RES.(dp) G.S
9、IZE Relationships RES. + SIZE DPI DPI G.DPI (mostly) G.DPI + RES. G.SIZE Effect of G.DPI Developers do not need to care about real density. RES.(px). are aggregated to RES.(dp). RES.(dp) has a much smaller range. devicedevice G.SIZEG.SIZE G.DPIG.DPI RES. RES. pxpx RES. RES. dpdp HTC wildfire small l
10、dpi 240*320 320*428dp HTC hero normal mdpi 320*480 320*480dp HTC desire normal hdpi 480*800 320*533dp HTC sensation normal hdpi 540*960 360*640dp Galaxy note normal xhdpi 800*1280 400*640dp Galaxy tab normal hdpi 600*1024 400*682dp Density independence 根据G.DPI,系统将dp units和drawables换算调整为 适配设备的大小(px).
11、 A Button (100*100dp) and a icon (48px*48px in mdpi) Go back to see first demo. Support general handset 如何支持普通手机? Handset features Small and Normal devices take over 90%. These devices are nearly all handsets. Handset qualifier G.SIZE: small/normal Default Orientation: portrait RES.(dp): 426dp x 320
12、dp - 640dp x 480dp. How to support? Develop a scalable app. Use wrap_content, fill_parent. Use dp not px. Use LinearLayout/RelativeLayout, not AbsoluteLayout. Provide different drawables for different dpi. Use more 9-patch drawable. A simple demo 320*480px mdpi 480*800px hdpi 540*960px hdpi 720*1280
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Android 屏幕 设备
链接地址:https://www.31doc.com/p-3329607.html