How to correctly size containing views
Posted
by Gerry
on Stack Overflow
See other posts from Stack Overflow
or by Gerry
Published on 2010-04-27T23:56:42Z
Indexed on
2010/04/28
0:03 UTC
Read the original article
Hit count: 247
I have an Activity that will display a custom view made up of 2 parts. I want one part to be 1/3 of visible screen height, the other part to be 2/3.
I can override onMeasure and use display metrics to find the height of the display, but this does not account for the battery bar or view title sizes.
DisplayMetrics dm = new DisplayMetrics(); ((WindowManager)contxt.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(dm); int height = dm.heightPixels;
How can I tell the height of the displayable area? I'm prepared to override the layout or whatever. What is the Android best practices? I've seen other questions along this line, but they are inconclusive.
© Stack Overflow or respective owner