You are currently viewing How to Disable landscape mode in Xamarin.Android?
Xamarin

How to Disable landscape mode in Xamarin.Android?

4.4
(13)

How to Disable landscape mode in Xamarin.Android?

If you want to Disable Landscape mode or Portrait mode in Xamarin.Android you need to set activity screen orientation attribute for that Activity.

Here is the example to Disable landscape mode in Xamarin.Android

 [Activity(Label = "@string/ApplicationName",ScreenOrientation =Android.Content.PM.ScreenOrientation.Portrait)]
    public class MainActivity : AppCompatActivity
{
    //.....
}

In the above example, we set ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait means this activity open with Portrait mode only. Activity remains in the Portrait mode while rotating the mobile.

Same as above you can Disable portrait mode in Xamarin.Android

 [Activity(Label = "@string/ApplicationName",ScreenOrientation =Android.Content.PM.ScreenOrientation.Landscape)]
    public class MainActivity : AppCompatActivity
{
    //.....
}

If your application related to so Gaming functionality then you might require Landscape mode only so you need to disable portrait mode as above example.

You may also like my other Android related posts: Android Posts

How useful was this post?

Click on a star to rate it!

Average rating 4.4 / 5. Vote count: 13

No votes so far! Be the first to rate this post.

As you found this post useful...

Share this post on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?