I have a screen size of 600 (width) x 1024 (height). I get current width 600 but incorrectly get height 976 (without rotated screen). I get current width 1024 but wrong get height 552 (with rotated screen).
int rowPixelWidth = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
int rowWidth = (int)Math.floor(rowPixelWidth / this.getResources().getDisplayMetrics().density);
int rowPixelheight = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight();
int rowheight = (int)Math.floor(rowPixelheight / this.getResources().getDisplayMetrics().density);
Log.d("rowWidth","rowWidth"+rowWidth);
Log.d("rowheight","rowheight"+rowheight);
-------------------------------------------------------------
<uses-sdk
android:minSdkVersion="3"
android:targetSdkVersion="8" />
<supports-screens android:anyDensity="true"/>
-------------------------------------------------------------
What's wrong with this code?
Here are some numbers for typical screen widths:
- 320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
- 480dp: a tweener tablet like the Streak (480x800 mdpi).
- 600dp: a 7” tablet (600x1024 mdpi).
- 720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
I get current width but not get current height for all device (without (320x480 screen).
I try code from Get screen dimensions in pixels but same occur problem.