简体   繁体   English

宽度和高度是否随方向而变化?

[英]Does the Width and Height change with orientation?

So my game starts in Vertical orientation and then eventually goes to Horizontal orientation. 所以我的游戏从垂直方向开始,然后最终进入水平方向。 I know that the width of the screen is the width of the screen and the same with height when it is in Vertical orientation. 我知道屏幕的宽度是屏幕的宽度,当它处于垂直方向时,它的高度是相同的。 When it switches to Horizontal orientation does the Height become the Width and the Width becomes the Height? 当它切换到水平方向时,高度是否变为宽度,宽度变为高度? Or do they stay the same? 或者他们保持不变?

Yes the screen width and height change depending on the device orientation. 是的,屏幕宽度和高度根据设备方向而变化。 You can get the size of a display with Display.getSize(Point outSize) which is a replacement for the deprecated methods Display.getHeight and Display.getWidth . 您可以使用Display.getSize(Point outSize)获取显示的大小,它取代了已弃用的方法Display.getHeightDisplay.getWidth From the docs: This value is adjusted for you based on the current rotation of the display. 从文档: 根据显示器的当前旋转为您调整此值。

wanted to add that on my tablet when running full screen apps it will run 1280 x 753 (not 800 because of the bottom bar). 我希望在运行全屏应用程序时在我的平板电脑上添加它,它将运行1280 x 753(因为底栏不是800)。 753 is what is returned from getSize. 753是getSize返回的内容。 When the orientation flips.. it's 1280px - 47px 当方向翻转时,它是1280px - 47px

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM