真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Android獲取屏幕尺寸實(shí)例代碼

Android 獲取屏幕尺寸實(shí)例代碼

站在用戶的角度思考問題,與客戶深入溝通,找到天橋網(wǎng)站設(shè)計(jì)與天橋網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、申請(qǐng)域名、網(wǎng)站空間、企業(yè)郵箱。業(yè)務(wù)覆蓋天橋地區(qū)。

實(shí)現(xiàn)代碼:

/** 
 *  
 *  
 * 使Android程序支持了多種分辨率 
 */ 
int mWidthScreen,mHeightScreen; 

Display display = getWindowManager().getDefaultDisplay(); 
mWidthScreen = display.getWidth(); 
mHeightScreen = display.getHeight(); 
LogUtils.e("Width:" + display.getWidth()); 
LogUtils.e("Height:" + display.getHeight()); 

WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE); 
DisplayMetrics outMetrics = new DisplayMetrics(); 
wm.getDefaultDisplay().getMetrics(outMetrics); 
mWidthScreen = outMetrics.widthPixels; 
mHeightScreen = outMetrics.heightPixels; 
LogUtils.e("Width:" + outMetrics.widthPixels); 
LogUtils.e("Height:" + outMetrics.heightPixels); 
LogUtils.e("xdpi:" + outMetrics.xdpi); 
LogUtils.e("ydpi:" + outMetrics.ydpi); 
LogUtils.e("densityDpi:" + outMetrics.densityDpi); 
LogUtils.e("density:" + outMetrics.density); 
LogUtils.e("scaledDensity:" + outMetrics.scaledDensity); 
LogUtils.e("spWidth:" + (outMetrics.widthPixels / outMetrics.scaledDensity + 0.5f)); 
LogUtils.e("spHeight:" + (outMetrics.heightPixels / outMetrics.scaledDensity + 0.5f)); 
LogUtils.e("dpWidth:" + (outMetrics.widthPixels / outMetrics.density + 0.5f)); 
LogUtils.e("dpHeight:" + (outMetrics.heightPixels / outMetrics.density + 0.5f)); 

DisplayMetrics resMetrics = getResources().getDisplayMetrics(); 
mHeightScreen = resMetrics.heightPixels; 
mWidthScreen = resMetrics.widthPixels; 
LogUtils.e("Width:" + resMetrics.widthPixels); 
LogUtils.e("Height:" + resMetrics.heightPixels); 
LogUtils.e("xdpi:" + resMetrics.xdpi); 
LogUtils.e("ydpi:" + resMetrics.ydpi); 
LogUtils.e("densityDpi:" + resMetrics.densityDpi); 
LogUtils.e("density:" + resMetrics.density); 
LogUtils.e("scaledDensity:" + resMetrics.scaledDensity); 
LogUtils.e("spWidth:" + (int)(resMetrics.widthPixels / resMetrics.scaledDensity + 0.5f)); 
LogUtils.e("spHeight:" + (int)(resMetrics.heightPixels / resMetrics.scaledDensity + 0.5f)); 
LogUtils.e("dpWidth:" + (resMetrics.widthPixels / resMetrics.density + 0.5f)); 
LogUtils.e("dpHeight:" + (resMetrics.heightPixels / resMetrics.density + 0.5f));

屏幕適配比

px dpi scale dip
480x850 240 1.5 320x569
540x960 240 1.5 360x640
640x960 320 2.0 320x480
600x1024 240 1.5 400x683
720x1280 240 1.5 480x853
720x1280 320 2.0 360x640
768x1280 320 2.0 384x640
800x1280 213 1.331 601x962
800x1280 320 2.0 400x640
1080x1920 420 2.625 411x731
1080x1920 480 3.0 360x640
1440x2560 560 3.5 411x731

感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!


網(wǎng)頁標(biāo)題:Android獲取屏幕尺寸實(shí)例代碼
分享URL:http://weahome.cn/article/gpgccj.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部