欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android獲取設(shè)備屏幕寬高pix值的方法

 更新時間:2018年05月03日 16:13:34   作者:安卓學(xué)習(xí)者  
這篇文章主要介紹了Android獲取設(shè)備屏幕寬高pix值的方法,需要的朋友可以參考下,具體內(nèi)容如下

本篇文章主要介紹了Android獲取設(shè)備屏幕寬高pix值的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

方法一:

WindowManager wm = (WindowManager) this 
.getSystemService(Context.WINDOW_SERVICE); 
int width = wm.getDefaultDisplay().getWidth(); 
int height = wm.getDefaultDisplay().getHeight(); 

方法二:

WindowManager wm1 = this.getWindowManager(); 
int width1 = wm1.getDefaultDisplay().getWidth(); 
int height1 = wm1.getDefaultDisplay().getHeight(); 

方法一與方法二獲取屏幕寬度的方法類似,只是獲取WindowManager 對象時的途徑不同。

方法三:

 WindowManager manager = this.getWindowManager(); 
DisplayMetrics outMetrics = new DisplayMetrics(); 
manager.getDefaultDisplay().getMetrics(outMetrics); 
int width2 = outMetrics.widthPixels; 
int height2 = outMetrics.heightPixels;

 方法四:

 Resources resources = this.getResources(); 
DisplayMetrics dm = resources.getDisplayMetrics(); 
float density1 = dm.density; 
int width3 = dm.widthPixels; 
int height3 = dm.heightPixels;

 方法三與方法四類似。

以上所述是小編給大家介紹的Android獲取設(shè)備屏幕寬高pix值的實(shí)例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評論