Problem locking Screen to Portrait mode for Android

2 posts, 0 answers
  1. Dmq
    Dmq avatar
    1 posts
    Member since:
    Jan 2016

    Posted 30 Jan Link to this post

    Hi, as the title says, I'm trying to lock the screen display to portrait mode, I've read other forums which suggested editing the AndroidManifest.xml and config.xml files, I've added the suggested config settings "see below" but still when I run the app in the device simulator, if I rotate the screen 90 Degrees it changes to landscape mode. I'm out of ideas for this so any help would be much appreciated.

     

    config.xml
    <preference name="orientation" value="portrait" />

    AndroidManifest.xml
    android:screenOrientation="portrait"

     

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 03 Feb Link to this post

    Hello,

    To achieve your goal, you can benefit from the verified Screen Orientation plugin. I would suggest you to try the following:
    1. subscribe for the deviceready event handler
    2. ensure the Screen Orientation plugin is installed (through General Project Properties
    3. add the code to lock the specific orientation on deviceready:

    // rotate and lock orientation to landscape
    window.screen.lockOrientation('landscape');


    Please note most of the plugins apart from the core plugins
    are not supported to be tested in the device simulator. They are to be tested on a device instead. For detailed reference on the plugins that the device simulator supports across the AppBuilder clients, you can check the table provided in the documentation.  There is a similar table on Limitations of the Companion App.

    Let me know how testing the suggested approach on a device works for you.

    Regards,
    Dimitrina
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
Back to Top