Friday, February 10, 2012

[android-developers] Re: How can I get the actual screen height ?

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 <renws1...@gmail.com> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment