简体   繁体   English

根据方向更改NativeScript XML布局

[英]Change NativeScript XML layout based on orientation

I have a question about NativeScript orientation (Landscape and Portrait). 我对NativeScript方向(横向和纵向)有疑问。

Is it possible to check if the device orientation is landscape or portrait and based on that switch the XML layout file? 是否可以检查设备方向是横向还是纵向,并根据该方向切换XML布局文件? For instance, use lay.land.xml for landscape and lay.port.xml for portrait. 例如,将lay.land.xml用于风景,将lay.port.xml用于肖像。

Thank's for all... 感谢所有...

NativeScript already does this out of the box. NativeScript已开箱即用。 Name your files <file-name>[.<qualifier>]*.<extension> 将文件<file-name>[.<qualifier>]*.<extension>

  • land - orientation is in landscape mode land -处于横向模式
  • port - orientation is in portrait mode port -方向为纵向模式

Note: All qualifiers are taken into account when the page is loading. 注意:加载页面时会考虑所有限定词。 However, changing the device orientation will not trigger page reload and will not change the current page. 但是,更改设备方向不会触发页面重新加载,也不会更改当前页面。

This is documented here: https://docs.nativescript.org/core-concepts/navigation#orientation-qualifiers 此处记录了以下内容: https : //docs.nativescript.org/core-concepts/navigation#orientation-qualifiers

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

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