tags:

views:

50

answers:

1

Hi,

How can I get the height of the device for portrait mode? I have to create a bitmap (which is zoomable) and I just want to get a rough idea what the tallest height should be.

getResources().getDisplayMetrics().heightPixels;

does the above return the height, in portrait mode only?

I'm not binding my UI to this absolute value, it's just a rough fit,

Thanks

+1  A: 
Display d = getWindowManager().getDefaultDisplay(); 
int potraitHeight = Math.max(d.getWidth(),d.getHeight());
steelbytes
@steelbytes: :thumbup:@user: You might also want to check this out:http://www.coderanch.com/t/435390/Android/Mobile/get-screen-size-at-run
Samuh
I strongly discourage you from getting the raw display size; this does not give you an accurate value for the space you will actually have.It is far better to use the normal view hierarchy facilities to see what size a view is given during layout, such as by overriding onSizeChanged().
hackbod
agreed about screen physical vs avaialble ... I just answered the literal Q.
steelbytes