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 开发者_JAVA技巧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);
try this::
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
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.
精彩评论