views:

54

answers:

2

Hi,

So i am trying to get the screen size of the Moto Droid on my application. on my Create, i am using the Service windowManager to get the default display.

Display display = getWindowManager().getDefaultDisplay();
    int width = display.getWidth(); 
    int height = display.getHeight();

When i set it i get width of 320 and height 570. that looks wrong, it should be 320x480. i want to place a 300x50 image on the bottom of the screen on any device (actually) so normally i would get the height of the screen and minus the image height so it places it on a view. but since i am getting 570 for some reason, i have to scroll down to see the image. why is it getting the wrong screen size and is there another more accurate way of getting the size. Thank you

Layout code goes as follows

   linearOut = new LinearLayout(this);
    linear = new LinearLayout(this);
    linear.setOrientation(LinearLayout.VERTICAL);


    scroll = new ScrollView(this);
    linearOut.addView(scroll);
    scroll.addView(linear);

            linear.addView(text);
    linear.addView(bbottom.getViewGroup());

    setContentView(linearOut);
+1  A: 

try this::

Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
    int width = display.getWidth(); 
    int height = display.getHeight();
Jorgesys
thanx for the quick response, unfortunately i still get the same resolution. does this 570 include the status bar?
robert.z
are you sure is a MotoDroid??? you must have a screen size of 854×480
Jorgesys
I have the actual device. yes, so i am assuming it is including the status bar height that is why my position of the image is off.
robert.z
Do you know a way to get the height of the status bar?
robert.z
yes ... http://stackoverflow.com/questions/3355367/height-of-statusbar/3356263#3356263
Jorgesys
ah perfect thanxk
robert.z
A: 

I think i got it. so the info above shows full screen viewable. so that does include the status bar. Is there a way to see the height of the status bar? i am not sure if all android devices have the same pixel height for the status bar.

robert.z