Multi-windows in Android 7.0 - Always get landscape layout even though device in multiwindows portrait mode

时间秒杀一切 提交于 2021-02-08 10:30:45

问题


I am developing an android application that supports multi-windows feature on Android 7.0. I followed this guide on https://developer.android.com. , imported sample project https://github.com/googlesamples/android-MultiWindowPlayground I create a new resource named layout-land and did some testing. I recognized that landscape layout is inflated even though the device is in portrait mode. Check out attached images. How can I set portrait layout when device is in portrait mode.


回答1:


Assume you have two screens. One is in landscape and one in portrait. How can you say which one is in landscape and which one in portrait?

In portrait width of the screen is less than height. And for landscape width of the screen is greater than height.

Agree?

So, here, when you enter multiwindow mode your app's window no longer fits screen - width is greater than height and it is considered as landscape. That is why landscape layout resource is used.

There is no separate modifier for layout resource to be used in split-screen mode.

The only thing you can do to achieve portrait in your case is to remove layout-land.

Or you can create two separate layouts (without any modifiers such as -land) and in activity call activity.isInMultiWindowMode(); to choose corresponding layout you want to use.



来源:https://stackoverflow.com/questions/42527558/multi-windows-in-android-7-0-always-get-landscape-layout-even-though-device-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!