根据方向更改 NativeScript XML 布局

Change NativeScript XML layout based on orientation

我有一个关于 NativeScript 方向(横向和纵向)的问题。

是否可以检查 设备方向 是横向还是纵向,并根据该切换 XML 布局文件?例如,横向使用 lay.land.xml,纵向使用 lay.port.xml

谢谢大家...

NativeScript 已经开箱即用。将文件命名为 <file-name>[.<qualifier>]*.<extension>

  • land - 方向为横向模式
  • 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.

此处记录:https://docs.nativescript.org/core-concepts/navigation#orientation-qualifiers