一、適配多分辨率
為天峻等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計制作服務(wù),及天峻網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為做網(wǎng)站、成都網(wǎng)站制作、天峻網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!
1.官網(wǎng)介紹: http://developer.android.com/guide/practices/screens_support.html#qualifiers
Screen characteristic | Qualifier | Description |
---|---|---|
Size | small | Resources for small size screens. |
normal | Resources for normal size screens. (This is the baseline size.) | |
large | Resources for large size screens. | |
xlarge | Resources for extra large size screens. | |
Density | ldpi | Resources for low-density (ldpi) screens (~120dpi). |
mdpi | Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.) | |
hdpi | Resources for high-density (hdpi) screens (~240dpi). | |
xhdpi | Resources for extra high-density (xhdpi) screens (~320dpi). | |
nodpi | Resources for all densities. These are density-independent resources. The system does not scale resources tagged with this qualifier, regardless of the current screen's density. | |
tvdpi | Resources for screens somewhere between mdpi and hdpi; approximately 213dpi. This is not considered a "primary" density group. It is mostly intended for televisions and most apps shouldn't need it—providing mdpi and hdpi resources is sufficient for most apps and the system will scale them as appropriate. If you find it necessary to provide tvdpi resources, you should size them at a factor of 1.33*mdpi. For example, a 100px x 100px p_w_picpath for mdpi screens should be 133px x 133px for tvdpi. | |
Orientation | land | Resources for screens in the landscape orientation (wide aspect ratio). |
port | Resources for screens in the portrait orientation (tall aspect ratio). | |
Aspect ratio | long | Resources for screens that have a significantly taller or wider aspect ratio (when in portrait or landscape orientation, respectively) than the baseline screen configuration. |
notlong | Resources for use screens that have an aspect ratio that is similar to the baseline screen configuration. |
關(guān)于布局文件適配的一些示例:
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml// layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
密度與尺寸定義的大概圖示:
2.關(guān)于屏幕大小的定義:
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp
在項目實作中,遇到一個問題,要對HVGA(320 * 480 px, density = 160), WVGA(480*800 px, density = 240) 和 QHD (540*960 px, density = 240) 進行適配, 換算成dp后,可以看到三種分辨率都是屬于values-normal范圍的,這下麻煩了,這三種屏幕尺寸差異很大,界面適配上必須要對應(yīng)不同的值,怎么辦呢?
解決方法很簡單,實際上qualifier是可以配置多個的,之間以"-"連接。
將values-normal 分成兩個目錄,即values-normal-mdpi, values-normal-hdpi, 其下分別對應(yīng)相應(yīng)的dimens.xml即可。values-normal-mdpi 對應(yīng) HVGA, values-normal-hdpi對應(yīng)WVGA和QHD。
3.圖標大小的設(shè)定
針對不同密度創(chuàng)建的圖標,你應(yīng)該遵循四個廣義密度之間的3:4:6:8縮放比例。例如,如果你有一個48 x48像素的圖標對應(yīng)于mdpi,則其他尺寸應(yīng)該是:
36x36 for low-density
48x48 for medium-density
72x72 for high-density
96x96 for extra high-density
4.比較典型的屏幕寬度尺寸
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).
5.尺寸與密度的一般對應(yīng)
Low density (120), ldpi | Medium density (160), mdpi | High density (240), hdpi | Extra high density (320), xhdpi | |
---|---|---|---|---|
Smallscreen | QVGA (240x320) | 480x640 | ||
Normalscreen | WQVGA400 (240x400) WQVGA432 (240x432) | HVGA (320x480) | WVGA800 (480x800) WVGA854 (480x854) 600x1024 | 640x960 |
Largescreen | WVGA800** (480x800) WVGA854** (480x854) | WVGA800* (480x800) WVGA854* (480x854) 600x1024 | ||
Extra Largescreen | 1024x600 | WXGA (1280x800) |
6.一個比較有代表性的軟件資源包結(jié)構(gòu)圖
7.drawable-nodpi的作用
把一些不能被拉伸的圖片放在 drawable-nodpi 中,此圖片將不會被放大,以原大小顯示。
但是寬和高要寫wrap_content,不要寫dip。
8.配置AndroidManifest.xml使應(yīng)用支持多分辨率
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true"/>
9.Android屏幕圖標尺寸一般規(guī)范
(1). 程序啟動圖標:
ldpi (120 dpi) 小屏 36 x 36 px
mdpi (160 dpi) 中屏 48 x 48 px
hdpi (240 dpi) 大屏 72 x 72 px
xhdpi (320 dpi) 特大屏 96 x 96 px
(2).底部菜單圖標
大屏:
1. 完整圖片(紅色): 72 x 72 px
2. 圖標(藍色): 48 x 48 px
3. 圖標外邊框(粉色): 44 x 44 px
中屏:
1. 完整圖片: 48 x 48 px
2. 圖標: 32 x 32 px
3. 圖標外邊框: 30 x 30 px
小屏:
1. 完整圖片: 36 x 36 px
2. 圖標: 24 x 24 px
3. 圖標外邊框: 22 x 22 px
(3). 彈出對話框頂部圖標
Low density screen (ldpi) 小屏 24 x 24 px
Medium density screen (mdpi) 中屏 32 x 32 px
High density screen (hdpi) 大屏 48 x 48 px
(4). 長列表內(nèi)部列表項圖標
Low density screen (ldpi) 小屏 24 x 24 px
Medium density screen (mdpi) 中屏 32 x 32 px
High density screen (hdpi) 大屏 48 x 48 px
(5). 底部或頂部tab標簽圖標
大屏 (hdpi):
1. 完整圖片(紅色): 48 x 48 px
2. 圖標(藍色): 42 x 42 px
中屏 (mdpi):
1. 完整圖片: 32 x 32 px
2. 圖標: 28 x 28 px
小屏(ldpi):
1. 完整圖片: 24 x 24 px
2. 圖標: 22 x 22 px
(6). 底部狀態(tài)欄圖標
ldpi (120 dpi) 小屏 18 x 18 px
mdpi (160 dpi) 中屏 24 x 24 px
hdpi (240 dpi) 大屏 36 x 36 px
xhdpi (320 dpi) 特大屏 48 x 48 px
本文標題:Android筆記:多分辨率適配及碎片化問題解決方案總結(jié)
網(wǎng)址分享:http://muchs.cn/article20/jehjco.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計、電子商務(wù)、Google、網(wǎng)站導(dǎo)航、外貿(mào)建站、網(wǎng)頁設(shè)計公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)