我有以下我的应用程序,以获取屏幕宽度和高度的代码:Android |获取屏幕高度,宽度和屏幕宽度,高度
screenHeight = (short) Activity.getWindow().getWindowManager().getDefaultDisplay().getHeight();
screenWidth = (short) Activity.getWindow().getWindowManager().getDefaultDisplay().getWidth();
而在AndroidManifest,我有:
<activity
android:name="com.test.MyActivity"
android:configChanges="keyboardHidden|orientation"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
</activity>
现在,对于屏幕分辨率为1280x700的设备,我期望screenWidth变量的值始终为1280,screenHeight为700.这与用户如何握住手机无关。
但仍然有时我得到screenWidth等于700和高度等于1280.为什么?我的清单文件不应该强制我的应用程序的方向始终保持风景吗?
我不明白这是一个问题。宽度/高度是相对于屏幕方向的,是的。一旦你知道了,你只需要相应地使用信息。 – njzk2 2013-02-21 10:09:38