Android 7.0中的多窗口-即使设备处于多窗口纵向模式,也始终获得横向布局 [英] Multi-windows in Android 7.0 - Always get landscape layout even though device in multiwindows portrait mode

查看:72
本文介绍了Android 7.0中的多窗口-即使设备处于多窗口纵向模式,也始终获得横向布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个支持Android 7.0上的多窗口功能的android应用程序.我在设备处于纵向模式时如何设置纵向布局.

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.

推荐答案

假设您有两个屏幕.一种是风景画,另一种是肖像画.你怎么说风景中的哪一个和肖像中的哪一个?

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.

同意吗?

因此,在这里,当您进入多窗口模式时,应用程序的窗口不再适合屏幕-宽度大于高度,被视为横向.这就是为什么使用景观布局资源的原因.

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.

或者您可以创建两个单独的布局(不带任何修饰符,例如 -land ),然后在活动调用中调用 activity.isInMultiWindowMode(); 选择您想要的相应布局使用.

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.

这篇关于Android 7.0中的多窗口-即使设备处于多窗口纵向模式,也始终获得横向布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆