How do I lock orientation

Hello,

I want to lock orientation in 'ReverseLandscape'.

I successed to lock orientation in 'Landscape'.
But did not prevent to change upside down.
How can I do lock orientation?

Answers

  • CasperSkouboCasperSkoubo USUniversity, Developer Group Leader

    So i guess you didn't hear that Google actually got a search engine?

    Anyway, you can read all about your problem developer.android.com

    android:screenOrientation=["unspecified" | "behind" |
                                         "landscape" | "portrait" |
                                         "reverseLandscape" | "reversePortrait" |
                                         "sensorLandscape" | "sensorPortrait" |
                                         "userLandscape" | "userPortrait" |
                                         "sensor" | "fullSensor" | "nosensor" |
                                         "user" | "fullUser" | "locked"]
    
  • TomohiroSuzukiTomohiroSuzuki JPMember ✭✭

    hello Skoubo

    I use Xamarin.Android.
    And I set attributes class definition section

       [Activity(
            Label = "BodyExplorer",
            AlwaysRetainTaskState = true,
            Icon = "@drawable/ic_launcher",
            Theme = "@android:style/Theme.NoTitleBar",
            ScreenOrientation = ScreenOrientation.ReverseLandscape,
            LaunchMode = LaunchMode.SingleInstance,
            MainLauncher = true,
            ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.KeyboardHidden
            )
        ]
        public class MainActivity : AndroidGameActivity, ISensorEventListener
        {
    

    But did not prevent to change upside down.
    Actually, ReverseLandscape and Landscape are enabled.

  • CasperSkouboCasperSkoubo USUniversity, Developer Group Leader

    and you only have 1 activity?

  • TomohiroSuzukiTomohiroSuzuki JPMember ✭✭

    Hello Skoubo,

    Thank you for your reply.

    I have a only 1 activity.

  • TomohiroSuzukiTomohiroSuzuki JPMember ✭✭

    I have successed to lock orientation in 'ReverseLandscape'.

    I override Property.

                public override ScreenOrientation RequestedOrientation
                {
                    get
                    {
                        return ScreenOrientation.ReverseLandscape;
                    }
                    set
                    {
                        base.RequestedOrientation = ScreenOrientation.ReverseLandscape;
                    }
                }
    

    Thank you!

Sign In or Register to comment.