That doesn't do what the original poster asked -- it doesn't take into account the title bar or status bar (or who knows what else may be around as screen decorations).
The correct way to do this is to wait until your view gets its size set. That is certainly the only place anyone knows about how the title bar / action bar are going to impact the space it has. On Fri, Feb 10, 2012 at 1:01 AM, Seshu <[email protected]> wrote: > Hi.. > > Use this function u ll get the width and height of the screens. > Display display = getWindowManager().getDefaultDisplay(); > int width = display.getWidth(); > int height = display.getHeight(); > > > Thanks and Regards, > S.Seshu > > > On Feb 10, 8:59 am, Wenshan <[email protected]> wrote: > > Hi, > > > > I'm trying to get the screen height, which is the > > DeviceScreenHeight - NavigationBarHeight - > > TitleBarHeight > > > > The code below always give me a 752, but the real screen height is 800. > > > > DisplayMetrics metrics = new DisplayMetrics(); > > getWindowManager().getDefaultDisplay().getMetrics(metrics); > > mHeight = metrics.heightPixels; > > > > And if I use onLayoutChange() to get the height of a vertically > > "match_parent" view, the height is 696. This is the value I need. > > > > But I want to know how to get this value dynamically so I can get the > > proper "height" on different devices. > > > > Android 3.2 > > > > Cheers, > > Wenshan > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

