欢迎来到我的的博客园,祝大家学有所成,早点实现自己的人生理想。

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);
            };
        }

    }
}

 

posted @ 2015-03-21 14:07  宋兴柱  阅读(4575)  评论(0编辑  收藏  举报