91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Android 獲取屏幕尺寸實例代碼

發布時間:2020-09-07 20:01:44 來源:腳本之家 閱讀:141 作者:小耳朵圖圖是我 欄目:移動開發

Android 獲取屏幕尺寸實例代碼

實現代碼:

/** 
 * <supports-screens 
 * android:smallScreens="true" 
 * android:normalScreens="true" 
 * android:largeScreens="true" 
 * android:resizeable="true" 
 * android:anyDensity="true" /> 
 * <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="8" /> 
 * 使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

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

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

阿克| 沿河| 大冶市| 苍梧县| 翁牛特旗| 乌鲁木齐市| 闽清县| 仙居县| 玛纳斯县| 沐川县| 镇江市| 博客| 翼城县| 开江县| 通榆县| 象山县| 绵阳市| 太谷县| 五莲县| 衡东县| 八宿县| 隆子县| 久治县| 班玛县| 库伦旗| 祁阳县| 吉隆县| 旺苍县| 田东县| 砀山县| 襄垣县| 伊宁市| 普定县| 霍邱县| 澳门| 安宁市| 思茅市| 茌平县| 开鲁县| 林周县| 靖安县|