简体   繁体   中英

Change NativeScript XML layout based on orientation

I have a question about NativeScript orientation (Landscape and Portrait).

Is it possible to check if the device orientation is landscape or portrait and based on that switch the XML layout file? For instance, use lay.land.xml for landscape and lay.port.xml for portrait.

Thank's for all...

NativeScript already does this out of the box. Name your files <file-name>[.<qualifier>]*.<extension>

  • land - orientation is in landscape mode
  • port - orientation is in portrait mode

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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