1

The following code returns the screen size:

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

I'm using RelativeLayout to arrange components inside. For some reason when I divide width between components (say width*30/100 and width*70/100) I get some screen space left out. And also about the height how can I get height of status bar and title bar does it vary among phones?

Sushan Ghimire
  • 7,307
  • 16
  • 38
  • 65

2 Answers2

1

this would help you. It states the difference in the sizes of status bar.

Community
  • 1
  • 1
Seshu Vinay
  • 13,560
  • 9
  • 60
  • 109
1

Answer is all in here

Quick summary: Android rounds up/down these values based on the nearest supported density/size ratio. You may not get the exact measurements you want, depending on your phone.

Also, Display is deprecated - use DisplayMetrics

josephus
  • 8,284
  • 1
  • 37
  • 57