my code:
Display display = activity.getWindowManager().getDefaultDisplay();
DisplayMetrics displayMetrics = new DisplayMetrics();
display.getMetrics(displayMetrics);
System.out.println("screen width:"+displayMetrics.widthPixels);
System.out.println("screen heigth:"+displayMetrics.heightPixels);
when I run this program in android Honeycomb system,the output is 800 and 1232 but the device's screen is 800_1280,hao can I get it? thanks.
This piece of code works for me (if you don't mind to use undocumented methods):
Actually device full screen
width=800 and height=1280
(including status bar, title bar)
. If you run your code to get display size, the system will not include status bar height and title bar height, so you will getheight as 1232 (1280-(status bar height + title bar height))
.1280 x 752 - landscape 800 x 1232 - portrait
This 48 px are for the Andriod default notification bar...