How do I disable orientation change on Android?

后端 未结 12 967
一向
一向 2020-11-22 02:45

I have an application that I just would like to use in portrait mode, so I have defined android:screenOrientation=\"portrait\" in the manifest XML. This works OK for the HTC

12条回答
  •  隐瞒了意图╮
    2020-11-22 02:56

    In Visual Studio Xamarin:

    1. Add:

    using Android.Content.PM; to you activity namespace list.

    1. Add:

    [Activity(ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait)]

    as an attribute to you class, like that:

    [Activity(ScreenOrientation = ScreenOrientation.Portrait)]
    public class MainActivity : Activity
    {...}
    

提交回复
热议问题