Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Get Screen size for the root Layout only
    text
    copied!<p>Please get me correctly over here : </p> <p>I want to get the height/width of the space available to the Activity/Layout in onCreate() method to calculate the height that can be given to child layouts. I can get the screen size using :</p> <pre><code> root = (LinearLayout) findViewById(R.id.mainroot); // Main layout of LinearLayout android.view.Display display = getWindowManager().getDefaultDisplay(); int height = Display.getHeight(); // I know this is deprecated have hence used int width = Display.getWidth(); // DisplayMetrics int childWidth, childHeight; DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics); //int density = metrics.densityDpi; height = metrics.heightPixels; //480 width = metrics.widthPixels; //320 </code></pre> <p>This both the methods/ways gives me same height and width i.e. size of full screen. What I am looking for is to get actual height that is avaialbe for the layout after deduction of Application Title, Status Bar, etc.</p> <p>Any idea how to get this. OR to get the sizes of titles, etc - what all should be counted over here. On emulator I see 2 bars on top - 1 must be application titile what an be the other one. I can get heights of them all and deduct from screen height. </p> <p>ONE more point : In this case I will be setting the height programamtically so it will be pixel based (as I can setheight in pixels only I guess) will that affect in density factor with differnet screen sizes. What can be a way to calculate height (lets say 50%) for child layout that will be same for any density o so.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload