关于适应不同屏幕的理解

首先,3.2以前是设置不同的small , normal, large, xlarge来解决

3.2以后通过设置最小的DP长度或者宽度来设置,比如layout-sw600dp

To help you target some of your designs for different types of devices, here are somenumbers for typical screen widths:

  • 320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
  • 480dp: a tweener tablet like the Streak (480x800 mdpi).
  • 600dp: a 7” tablet (600x1024 mdpi).
  • 720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
res/layout/main_activity.xml           # For handsets
res/layout-sw600dp/main_activity.xml   # For tablets


还要在manifest里设置下最小的那个长度或者宽度。

<manifest ... >
    <supports-screens android:requiresSmallestWidthDp="600" />
    ...
</manifest>


  1. Use wrap_content, fill_parent, or dp units when specifyingdimensions in an XML layout file
  2. Do not use hard coded pixel values in your application code
  3. Do not use AbsoluteLayout (it's deprecated)
  4. Supply alternative bitmap drawables for different screen densities
      1. 用wrap_content , fill_content,  和dp为单位的布局,(事实证明非常好用)

      2 不要用固定的PX为单位

      3. 不要用绝对布局

      4. 设置不同分辨率的图片自适应



  Low density (120), ldpi Medium density (160), mdpi High density (240), hdpi Extra high density (320), xhdpi
Small screenQVGA (240x320) 480x640 
Normal screenWQVGA400 (240x400)
WQVGA432 (240x432)
HVGA (320x480)WVGA800 (480x800)
WVGA854 (480x854)

600x1024
640x960
Large screenWVGA800** (480x800)
WVGA854** (480x854)
WVGA800* (480x800)
WVGA854* (480x854)

600x1024
  
Extra Large screen1024x600WXGA (1280x800)
1024x768
1280x768
1536x1152
1920x1152
1920x1200
2048x1536
2560x1536
2560x1600
* To emulate this configuration, specify acustom density of 160 when creating an AVD that uses a WVGA800 or WVGA854 skin.
** To emulate this configuration, specify a custom density of 120 when creating an AVD thatuses a WVGA800 or WVGA854 skin.
† This skin is available with the Android 3.0 platform


用以上属性来测试不同屏幕效果

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值