How can I set Orientation Fixed for all activities

后端 未结 5 1982
半阙折子戏
半阙折子戏 2020-12-09 23:20

Android Layout. How can I set Orientation Fixed for all activities in application Tag of AndroidMainfest.xml ? I don\'t want to set orientation for each activity individuall

5条回答
  •  轮回少年
    2020-12-09 23:54

    (Monodroid/C# code)

    You can create an abstract base class

    public abstract class ActBase : Activity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestedOrientation = clsUtilidades.GetScreenOrientation();
        }
     }
    

    Then all your activities must inherit this class instead Activity

    Somehting like

    [Activity(Label = "Orders", ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.Mcc | ConfigChanges.Mnc)]
    public class ActOrders : ActBase
    {
      ....
    

    This way avoids call the ActivityHelper in your events

提交回复
热议问题