Orientation Landscape and Reverse Landscape

4 posts, 1 answers
  1. Alfonso
    Alfonso avatar
    16 posts
    Member since:
    Jun 2008

    Posted 22 May 2014 Link to this post

    Dir Sir/Madam,

    I am trying to allow an app to rotate but only in landscape modes.

    This is both for Android and IOS.

    If we disable portrait mode in the project, then the app opens in landscape mode, but it does not rotate, so if I turn it 180º, (reverse landscape) the app will be upside down. We need the app to rotate.
    If we enable landscape, and portrait mode then it works in reverse landscape, but we don't know how to avoid the portrait modes.

    Is there anyway to achieve this in Android and IOS.

    Thanks in advance,

    Best regards,

    Alfonso de las Heras.
  2. Alfonso
    Alfonso avatar
    16 posts
    Member since:
    Jun 2008

    Posted 22 May 2014 in reply to Alfonso Link to this post

    I have been able to do this on iOS:

    function shouldRotateToOrientation(orientation) {
    //    alert(orientation);

        switch (orientation) {
            case 0:
                return false;
            case 180:
                console.log("Portrait");
                return false;
                //LandscapeRight or LandscapeLeft
            case 90:
                return true;
            case -90:
                console.log("Landscape");
                return true;
        }
        
    }




    But i don't know how to do the same in Android.

    Thanks.
  3. Answer
    Tsvetomir
    Admin
    Tsvetomir avatar
    17 posts

    Posted 23 May 2014 Link to this post

    Hello Alfonso,

    You can enable landscape and reverse landscape screen orientation by performing these steps:
    • Go to Project Properties and disable portrait mode
    • For iOS:
      • Open iOS Config.xml (Right click on Project -> Edit Configuration)
      • Add this preference : <preference name="orientation" value="landscape" />, you can find more information in the orientation segment here.
    • For Android (the steps below will be available in the 2.2 release of AppBuilder, scheduled for two weeks from now)
      • Open Android Manifest.xml (Right click on project -> Edit Configuration)
      • In the activity element add this android:screenOrientation="sensorLandscape", you can find more information about android screen orientations here.

    I hope this helps.

    Kind Regards,
    Tsvetomir
    Telerik
     

    Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!

     
  4. Alfonso
    Alfonso avatar
    16 posts
    Member since:
    Jun 2008

    Posted 23 May 2014 in reply to Tsvetomir Link to this post

    Thank you Tsvetomir,

    Those steps worked for the iOS version.
    We will wait for the 2.2 version of apppbuilder to test it on Android.

    Thank you very much for your help.

    Best regards,

    Alfonso.
Back to Top