0

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);
rbz
  • 759
  • 1
  • 8
  • 17

2 Answers2

1

try this::

Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
    int width = display.getWidth(); 
    int height = display.getHeight();
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
  • thanx for the quick response, unfortunately i still get the same resolution. does this 570 include the status bar? – rbz Sep 02 '10 at 22:38
  • 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. – rbz Sep 02 '10 at 23:06
  • Do you know a way to get the height of the status bar? – rbz Sep 02 '10 at 23:07
  • yes ... http://stackoverflow.com/questions/3355367/height-of-statusbar/3356263#3356263 – Jorgesys Sep 03 '10 at 15:22
0

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.

rbz
  • 759
  • 1
  • 8
  • 17