• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

How do I determine Android Screen Width/Height?

Community Beginner ,
Sep 13, 2011 Sep 13, 2011

Copy link to clipboard

Copied

Hello,

I've done a Google Search for finding the screen size in Android, but only found Java code(which I can't use).

The closest thing I found was:

maxwidth=stage.stageWidth;

maxheight=stage.stageHeight;

And they seemed reasonable, however when I drew an object at maxwidth on my HTC Sensation, it only drew in about the middle of the screen.

So I am very confused.  A person simply cannot write Aps for Android unless they can get screen size because everyone's phone is different.

Any help?

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 13, 2011 Sep 13, 2011

Copy link to clipboard

Copied

Found a thread that said:

stage.fullScreenHeight

and

stage.fullScreenWidth

But they were also wrong numbers.

The width was maybe 60% across the screen, not at the very end.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 13, 2011 Sep 13, 2011

Copy link to clipboard

Copied

I don't need an answer very fast because I can still develop for my own resolution and tweak later once I get this code.

I do have a game you can play for free here:

http://www.goodnewsjim.com/DiamondDrop/HowToPlay.html

Which I ported to Android.

But no one can play it because everyone has different resolution phones

Someday, I'll have an ap on the Market

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 15, 2011 Sep 15, 2011

Copy link to clipboard

Copied

What is interesting is that:

    w=stage.fullScreenWidth;
    h=stage.fullScreenHeight;

Works for the emulated devices, but not my actual physical HTC Sensation

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 17, 2011 Sep 17, 2011

Copy link to clipboard

Copied

LATEST

Ok, it seems like:

w=stage.fullScreenWidth;

    h=stage.fullScreenHeight;

works properly

I checked by detecting mouseclicks, and the edge was 958 and w=stage.fullScreenWidth; gives w=960.

The problem comes in when I put something at x=900.  Instead of being almost off the screen to the right, it is almost in the middle of the screen (60% in from the left).

Anyone know why this might happen on an HTC Sensation?        

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines