Just use t他功能下面,返回屏幕尺寸的高度和寬度爲整數
private int[] getScreenSIze(){
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int h = displaymetrics.heightPixels;
int w = displaymetrics.widthPixels;
int[] size={w,h};
return size;
}
在您的onCreate功能或按鈕的陣列單擊下面的代碼添加到輸出的屏幕尺寸如下所示
int[] screenSize= getScreenSIze();
int width=screenSize[0];
int height=screenSize[1];
screenSizes.setText("Phone Screen sizes \n\n width = "+width+" \n Height = "+height);
見:http://stackoverflow.com/questions/1016896/android-how-to-get-screen-dimensions – 2011-01-20 03:18:01