androidandroid-layoutscreen-orientationsplit-screen

Android SplitScreen orientation


I have an issue.

I have a method which checks if screen is in landscape mode:

private boolean isLandscape() {
    final Resources resources = getResources();

    return resources != null && resources.getConfiguration() != null
            && resources.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
}

It works perfectly when screen is not split. The problem is the next:

It returns false when screen is split. In this case resources.getConfiguration().orientation returns ORIENTATION_PORTRAIT. I have read android reference(#1, #2), but I did not found any information.

Any suggestions?


Solution

  • Thankfully to the link provided by Stallion, I found the reason:

    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.

    See this link for more information.