I'm currently developping my app to be compatible with the samsung multi window feature introduced with the galaxy note 2 and soon the galaxy s3. If you don't know what I'm talking about :
(source: androidheadlines.com)

If you are interested, here is a link to know how to do it : here

My problem is that I need to know the height/width that my app uses. I'm doing this :

displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
heightScreen = displaymetrics.heightPixels;
widthScreen = displaymetrics.widthPixels;

But this returns the size of the entire screen, not just the part that my app uses. My activity is only compose by a Panel which take the entire space, but the panel.getHeight() or getWidth() return 0.

How can I get the real height/width ?

Thanks in advance.

有帮助吗?

解决方案

My activity is only compose by a Panel which take the entire space, but the panel.getHeight() or getWidth() return 0.

Try checking later. You are probably checking for this in onCreate(), which is too soon AFAIK.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top