關於適應不同屏幕的理解

首先,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 screen QVGA (240x320)   480x640  
Normal screen WQVGA400 (240x400)
WQVGA432 (240x432)
HVGA (320x480) WVGA800 (480x800)
WVGA854 (480x854)

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

600x1024
   
Extra Large screen 1024x600 WXGA (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


用以上屬性來測試不同屏幕效果

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章