2012-05-04 82 views
0

我正在寫一個動態壁紙。和以前一樣,我在「onSurfaceChanged」處獲得用戶的屏幕寬度&高度。我可以在「onSurfaceCreated」上獲得屏幕寬度&高度嗎?用戶手機屏幕尺寸

+0

誰能教我? – Perry

回答

2

你可以在任何地方,你得到的屏幕尺寸就像使用

getWallpaperDesiredMinimumWidth()/2 

或 把

WindowManager wm = (WindowManager)getSystemService(WINDOW_SERVICE); 
DisplayMetrics metrics; 
disp = wm.getDefaultDisplay(); 

在源的頂部,並做

disp.getMetrics(metrics); 
screenWidth = (float) metrics.widthPixels;