Android 分屏方向
Android SplitScreen orientation
我有一个问题。
我有一个方法可以检查屏幕是否处于横向模式:
private boolean isLandscape() {
final Resources resources = getResources();
return resources != null && resources.getConfiguration() != null
&& resources.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
}
在不分屏的情况下完美运行。
问题是下一个:
它 returns false
当屏幕被分割时。
在这种情况下 resources.getConfiguration().orientation
returns ORIENTATION_PORTRAIT
。我已经阅读了 android 参考资料(#1, #2),但我没有找到任何信息。
- 设备:Nexus 5x
- OS: Android 7.0
有什么建议吗?
感谢Stallion提供的link,我找到了原因:
Turns out: “portrait” really just means the height is greater than the width and “landscape” means the width is greater than the height. So it certainly makes sense, with that definition in mind, that your app could transition from one to the other while being resized.
有关详细信息,请参阅 this link。
我有一个问题。
我有一个方法可以检查屏幕是否处于横向模式:
private boolean isLandscape() {
final Resources resources = getResources();
return resources != null && resources.getConfiguration() != null
&& resources.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
}
在不分屏的情况下完美运行。 问题是下一个:
它 returns false
当屏幕被分割时。
在这种情况下 resources.getConfiguration().orientation
returns ORIENTATION_PORTRAIT
。我已经阅读了 android 参考资料(#1, #2),但我没有找到任何信息。
- 设备:Nexus 5x
- OS: Android 7.0
有什么建议吗?
感谢Stallion提供的link,我找到了原因:
Turns out: “portrait” really just means the height is greater than the width and “landscape” means the width is greater than the height. So it certainly makes sense, with that definition in mind, that your app could transition from one to the other while being resized.
有关详细信息,请参阅 this link。