Re: Resoution discrepency
Just a thought but could it be the pixels on the bottom of the screen for the navigation bar controlls and such.
Re: Resoution discrepency
The resolution available to your application itself will be the current statusbar and navbar height subtracted from the full current height. On a device running the tablet UI, they are typically combined at the bottom. If you'd like the application to run in a full-screen mode, try one of the following:
In your manifest:
Code:
<application
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
You can also declare this at the activity level in your manifest, if you only want specific activities to run fullscreen.
Alternatively, in your activity's onCreate:
Code:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Call these two methods after super.onCreate() and before setContentView().
Re: Resoution discrepency
Hey, thanks for the suggestions, unfortunately, I'm already running without status bar - but maybe there's something else I need to do in Jelly bean? I mean a phone with a 800 x 480 res is reporting exactly that once running without status bar, but the nexus, doesn't - it's really odd. The bar does disappear. (I am using the first method, application level declaration in the manifest)
Re: Resoution discrepency
Quote:
Hey, thanks for the suggestions, unfortunately, I'm already running without status bar - but maybe there's something else I need to do in Jelly bean? I mean a phone with a 800 x 480 res is reporting exactly that once running without status bar, but the nexus, doesn't - it's really odd. The bar does disappear. (I am using the first method, application level declaration in the manifest)
Unfortunately I won't have access to my Nexus 10 for a few days, so I can't do any specific testing for you. If your goal here is simply to get information pertaining to the display itself (such as physical resolution), I would look at using the [Only registered and activated users can see links. Click Here To Register...].
Code:
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
You should be able to use public int heightPixels and public float ydpi do perform basic calculations, but I should caution you that if this application is intended for more than personal use (i.e. it will be distributed, via the Play Store or other channels), carrying out actions based on the display's physical dimensions may lead to fragmentation issues similar to the one you're already trying to solve.
Additionally, there are methods of determining the height of the statusbar/navbar on the screen, which theoretically could be used in conjunction with the above code for accessing the display size in order to determine the remaining space for your application. But again, I should note that you may run into fragmentation issues when you start relying on such calculations.
Re: Resoution discrepency
Thanks mate, I'm using a similar method - but I will try the code you posted. I'm passing it from my activity into my SurfaceView class and using it for a full screen canvas. I need to do it this way as I need to know what size the canvas is going to be before it's been created (for created scaled bitmaps etc). It will be published on the Play Store eventually. It just kind of threw me because every other device I've tested it on returns the correct device resolution. Strange! :-\