Xamarin 中开发Android实现全屏或者不显示标题栏的方法-宋兴柱

using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace AndroidDemo
{
    [Activity(Label = "Android", MainLauncher = true, Icon = "@drawable/AppIcon")]//Theme = "@android:style/Theme.NoTitleBar.Fullscreen"
    public class MainActivity : Activity
    {
        protected override void OnCreate(Bundle bundle)
        {
            this.SetTheme(Android.Resource.Style.ThemeNoTitleBarFullScreen);//全屏并且无标题栏,必须在OnCreate前面设置。
            //this.Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);//只设置本页全屏
            //this.RequestWindowFeature(WindowFeatures.NoTitle);//只设置无标题栏
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);
            FindViewById<Button>(Resource.Id.button1).Click += (ss, ee) => { this.StartActivity(typeof(Views.GalleryDemo.GallleryActivity)); };
            FindViewById<Button>(Resource.Id.button2).Click += (ss, ee) =>
            {
                this.StartActivity(typeof(Views.ImageButtonActivity));
                //this.OverridePendingTransition(Resource.Animation.enterfrombottom_anim, Resource.Animation.outtobottom_anim);
                this.OverridePendingTransition(Android.Resource.Animation.FadeIn, Android.Resource.Animation.FadeOut);
            };
        }

    }
}

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。